在使用PowerDesigner对数据库进行概念模型和物理模型设计时,一般在NAME或Comment中写中文,在Code中写英文。Name用来显 示,Code在代码中使用,但Comment中的文字会保存到数据库Table或Column的Comment中,当Name已经存在的时候,再写一次 Comment很麻烦,可以使用以下代码来解决这个问题:
代码一:将Name中的字符COPY至Comment中
- Option Explicit
- ValidationMode = True
- InteractiveMode = im_Batch
-
- Dim mdl ' the current model
-
- ' get the current active model
- Set mdl = ActiveModel
- If (mdl Is Nothing) Then
-
MsgBox "There is no current Model "
- ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then
-
MsgBox "The current model is not an Physical Data model. "
- Else
- ProcessFolder mdl
- End If
-
-
' This routine copy name into comment for each table, each column and each view
- ' of the current folder
- Private sub ProcessFolder(folder)
- Dim Tab 'running table
-
for each Tab in folder.tables
-
if not tab.isShortcut then
- tab.comment = tab.name
- Dim col ' running column
-
for each col in tab.columns
- col.comment= col.name
- next
-
end if
- next
-
- Dim view 'running view
-
for each view in folder.Views
-
if not view.isShortcut then
- view.comment = view.name
-
end if
- next
-
- ' go into the sub-packages
- Dim f ' running folder
- For Each f In folder.Packages
-
if not f.IsShortcut then
- ProcessFolder f
-
end if
- Next
- end sub
注意:如果不想把以前写的注释给覆盖掉 ,那么把上面的红色标记处 改成: col.comment= col.name + col.comment 那么注释就是追加的了
另外在使用REVERSE ENGINEER从数据库反向生成PDM的时候,PDM中的表的NAME和CODE事实上都是CODE,为了把NAME替换为数据库中Table或Column的中文Comment,可以使用以下脚本:
代码二:将Comment中的字符COPY至Name中
- Option Explicit
- ValidationMode = True
- InteractiveMode = im_Batch
-
- Dim mdl ' the current model
-
- ' get the current active model
- Set mdl = ActiveModel
- If (mdl Is Nothing) Then
-
MsgBox "There is no current Model "
- ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then
-
MsgBox "The current model is not an Physical Data model. "
- Else
- ProcessFolder mdl
- End If
-
- Private sub ProcessFolder(folder)
- On Error Resume Next
- Dim Tab 'running table
-
for each Tab in folder.tables
-
if not tab.isShortcut then
- tab.name = tab.comment
- Dim col ' running column
-
for each col in tab.columns
-
if col.comment="" then
-
else
- col.name= col.comment
-
end if
- next
-
end if
- next
-
- Dim view 'running view
-
for each view in folder.Views
-
if not view.isShortcut then
- view.name = view.comment
-
end if
- next
-
- ' go into the sub-packages
- Dim f ' running folder
- For Each f In folder.Packages
-
if not f.IsShortcut then
- ProcessFolder f
-
end if
- Next
- end sub
以上两段代码都是VB脚本,在PowerDesigner中使用方法为:
PowerDesigner->Tools->Execute Commands->Edit/Run Scripts
将代码Copy进去执行就可以了,是对整个CDM或PDM进行操作
分享到:
相关推荐
保存这个脚本为“name变成注释.vbs”,然后在“Execute Commands”的“Script File”(脚本文件)框中选择这个文件。点击“Run”(运行)按钮,脚本会开始执行,将所有符合条件的字段名称自动填充到对应的注释中。 ...
powerdesigner逆向工程导入mysql脚本生成PDM带全注释
通过取消“Name to Code mirroring”复选框,我们可以让 Code 不与 Name 一起联动,从而解决 PowerDesigner 中 Name 与 Code 同步的问题。 PowerDesigner 中的 Name 与 Code -------------------------------- 在 ...
一个小脚本,可以让powerdesigner显示的ER图添加注释,不过需要做一些设置
PowerDesigner是一款功能强大的数据模型设计工具,但是在某些版本中,视图不支持同时显示name、code、comment(列注释)。本文档将介绍如何在PowerDesigner中显示name、code、comment,解决了这个问题。 问题描述:...
在PowerDesigner这款数据建模和设计工具中,name和comment的互换是一个重要的操作...通过理解和实践PowerDesigner中的name和comment互换脚本,可以进一步加深对数据模型结构和属性的理解,提升处理数据模型的专业能力。
PowerDesigner中的name属性通常用于定义对象的唯一标识,比如表名、字段名等,而comment则用于添加对这些对象的描述性注释。在某些情况下,用户可能需要批量修改或交换这些属性,比如在整理模型文档时,为了保持一致...
PowerDesigner 导出的 SQL 带列注释,导入到 MySQL 中列注释不见了的处理方法 在使用 PowerDesigner 导出 SQL 文件时,如果包含列注释,可能会在导入到 MySQL 数据库中时丢失。这是因为 PowerDesigner 导出的 SQL ...
在使用PowerDesigner的过程中,有时会遇到一个常见的问题,即Name(名称)与Code(代码)同步的问题。这个问题指的是当用户修改了一个实体或字段的Name时,其对应的Code也会自动更新,这可能不符合开发者的预期,...
powerDesigner 把name项添加到comment 使用方法使用方法 PowerDesigner->Tools->Execute Commands->Edit/Run Scripts 可以保存该脚本为:name2comment.vbs
在 PowerDesigner 中,表的注释默认情况下不显示。要显示表的注释,需要按照以下步骤操作: 1. 打开工具菜单:点击“Tools”菜单,然后选择“Display Preferences”。 2. 选择表:选择要显示注释的表,然后点击...
### PowerDesigner连接MySQL互相导入及显示中文注释详解 #### 一、安装ODBC驱动 在进行PowerDesigner与MySQL之间的连接之前,首先需要确保已经安装了ODBC (Open Database Connectivity) 驱动。ODBC驱动是实现不同...
本文将深入探讨如何使用PowerDesigner进行MySQL数据库的逆向工程,并解决逆向工程过程中可能出现的没有注释的问题。 首先,让我们了解什么是逆向工程。逆向工程,也称为数据库反向设计,是指从已有的数据库中提取其...
在本篇中,我们将探讨如何使用PowerDesigner批量生成SQL脚本来将name属性转换为数据库中字段的comment。 首先,我们需要了解PowerDesigner中的PDM(Physical Data Model),这是一个物理数据模型,它包含了数据库的...
标题中的“PowerDesigner 把name写到Comment中 和 把Comment写到name中 pd7以后版本可用”指的是一项在PowerDesigner中操作模型属性的方法。PowerDesigner是一款强大的数据建模工具,广泛应用于数据库设计和逆向工程...
当PowerDesigner连接好数据库,并生成模型后,在PowerDesigner用Ctrl+Shift+x快捷键打开,然后将脚本内容粘贴运行,就可以开始生成数据库中存在的注释了
标题“powerdesigner_comment转name_name转comment”指的是使用PowerDesigner工具进行数据库设计时,将字段注释(comment)与字段名(name)之间进行互相转换的功能。在数据库设计过程中,注释对于理解和维护数据库...
标题中的"powerdesigner生成含注释的sql"指的是使用PowerDesigner这款强大的数据库设计工具来创建包含注释的SQL脚本。PowerDesigner是一款流行的数据建模工具,它可以帮助IT专业人员进行概念数据模型(CDM)、物理...
在默认情况下,PowerDesigner并不直接显示模型中的对象注释,这对于理解和维护复杂的数据库模型可能会造成不便。"显示注释程序"正是为了解决这个问题而存在的,它是一个VBS(Visual Basic Script)脚本,能够帮助...
这段脚本将COMMENT中的字符复制到NAME中,确保NAME反映数据库的实际注释。 由于给出的文件内容不完整,无法提供完整的代码二。不过,其基本思路是遍历所有表和列,检查COMMENT字段,并将其内容移动到NAME字段。一旦...