一键搞定PowerDesigner的Name转换Comment
在数据库设计过程中,PowerDesigner的Name(名称)和Comment(注释)字段处理常常让人头疼。今天介绍一个高效的批量转换方法,让你彻底告别手动操作的繁琐。
🔧 脚本实现:Name转Comment
适用场景:需要将英文名称批量转换为中文注释时
操作步骤:
-
打开PowerDesigner物理数据模型
-
进入
Tools→Execute Commands→Edit/Run Script... -
复制以下代码到脚本窗口:
Option ExplicitValidationMode = TrueInteractiveMode = im_Batch
Dim mdl 'the current model
'get the current active modelSet mdl = ActiveModelIf (mdl Is Nothing) ThenMsgBox "There is no current Model"ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) ThenMsgBox "The current model is not an Physical Data model."ElseProcessFolder mdlEnd If
'This routine copy name into code for each table, each column and each view'of the current folderPrivate sub ProcessFolder(folder)Dim Tab 'running tablefor each Tab in folder.tablesif not tab.isShortcut then
Dim col 'running columnfor each col in tab.columnsIf (col.comment="") Then '已存在的comment则不更新col.comment= col.nameend ifnextend ifnext
Dim view 'running viewfor each view in folder.Viewsif not view.isShortcut thenview.comment = view.nameend ifnext
'go into the sub-packagesDim f 'running folderFor Each f In folder.Packagesif not f.IsShortcut thenProcessFolder fend ifNextend sub
- 点击
Run执行脚本

浙公网安备 33010602011771号