一、版本说明
任何不上版本的教程都是耍流氓,本教程采用16.5版本PowerDesigner。
二、table中无comment(注释)的处理方案
1、效果图:
2、操作步骤:
1). 双击表,进入如下所示界面,点击如下图红色图标:
2). 找到Comment,然后勾选,完结。
三、取消table中name与code的联动
1、目标:当输入name时,code不发生联动。
2、操作步骤:Tools --> General Options --> Dialog --> 取消如图所示勾选,收工。
四、绑定Table中Name与Comment联动
1、目标:
1). 在PowerDesigner中编写好数据库后,要求生成Comment与Name相同(此时Name有值,Comment没有)。
2). 通过sql导入数据库至powerdesign中后,要求生成Name与Comment相同(此时Comment有值,Name没有)。
2、操作步骤:
为实现如上两个目标,需通过VB代码来完成。执行过程(快捷键:ctrl + shift + x):Tools --> Execute Commands --> Edit/Run Script。
1). name2Comment:(name -- > 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
2). comment2Name:(comment --> 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
五、参考资料:
https://www.cnblogs.com/codecat/p/10830876.html
https://jingyan.baidu.com/article/1e5468f94d9ea3484861b773.html