天天看点

PowerDesigner逆向工程,展示表及字段备注

打开PowerDesigner,操作如下

PowerDesigner逆向工程,展示表及字段备注
PowerDesigner逆向工程,展示表及字段备注
PowerDesigner逆向工程,展示表及字段备注
PowerDesigner逆向工程,展示表及字段备注
PowerDesigner逆向工程,展示表及字段备注
PowerDesigner逆向工程,展示表及字段备注

点击确定后。会列出全部数据的表格。

PowerDesigner逆向工程,展示表及字段备注

可以在:<All users>那里选择我们想要的库

PowerDesigner逆向工程,展示表及字段备注

然后可以通过: Select ALL和Deselect All全选和全不选。

PowerDesigner逆向工程,展示表及字段备注
PowerDesigner逆向工程,展示表及字段备注

选择想要的表,然后点击OK。显示如下:

PowerDesigner逆向工程,展示表及字段备注

四、显示中文注释

导是导入成功了,但是并没有显示中文注释,显示表的中文注释操作如下:

在tool中选择Display Preferences

PowerDesigner逆向工程,展示表及字段备注
PowerDesigner逆向工程,展示表及字段备注

在Table中选择Comment

PowerDesigner逆向工程,展示表及字段备注

然后点击OK。这样表的注释就有了,问题是还有字段的注释没有,选中Table,右键Properties,会发现其中已经有了Comment,一栏

PowerDesigner逆向工程,展示表及字段备注

问题是没有在PDM图上显示。解决方法如下,要将注释comment的内容替换到code或name中,即可。步骤如下:

1、Tools->Display Preferences->Table->Advanced...->Columns->List Columns

PowerDesigner逆向工程,展示表及字段备注

然后将Code移到最上面

PowerDesigner逆向工程,展示表及字段备注

然后点击OK。

2、Tools下增加一个vbs的脚本,可以将code内容替换为注释内容

PowerDesigner逆向工程,展示表及字段备注

复制脚本执行。即可

PowerDesigner逆向工程,展示表及字段备注

vbs文件内容如下(注意需要管理员运行):

Option   Explicit   
    ValidationMode   =   True   
    InteractiveMode   =   im_Batch
    Dim blankStr
    blankStr   =   Space(1)
    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 = "" or replace(col.comment," ", "")="" Then
                            col.name = blankStr
                            blankStr = blankStr & Space(1)
                      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  
           

执行成功后,效果如下

PowerDesigner逆向工程,展示表及字段备注

替换后的字段如下

PowerDesigner逆向工程,展示表及字段备注