天天看點

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逆向工程,展示表及字段備注