目錄:
- 數據庫的反向生成模型
- 模型的Cooment注釋顯示
步驟一:下載odbc驅動並進行安裝:
(1)下載
mysql-connector-odbc-5.3.4-win32
注意:不管電腦是32位,還是64位,統一安裝32位即可。
(2)安裝
步驟二:odbcad32.exe添加數據源
找到C:\Windows\SysWOW64目錄下找到odbcad32.exe這個文件
雙擊打開,彈出ODBC數據源管理界面
點擊添加按鈕,在彈出的窗口中選中,安裝好的驅動:
點擊完成,彈出數據庫信息創建窗體:
點擊后Ok后,即可以看到新增加了選項:
配置完成。
步驟三:數據庫導出為Sql腳本文件
步驟四:打開PowerDesigner軟件,進行導入生成模型
A、選擇菜單,導入數據源
B.選擇數據庫版本
C.點擊添加Sql文件
D.點擊確定后,即可進行轉換,生成想要的數據庫模型
步驟五,設置顯示備注信息:
A、雙擊表,進入編輯模式,注意:表和列記得添加注釋,如下圖所示:
點擊下圖按鈕:
B、勾選Comment的多選框
C、打開執行腳本編輯窗口
D、執行以下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
E、執行后,即可發現注釋已經正常現示:
步驟六:顯示原字段名
點擊Ok后,會彈出確認框,默認選擇確定后即可看到效果:
步驟七:更改顯示的順序:
調整后效果:
數據庫反向生成模型結束!