Mysql 將表結構匯入 Powerdesigner ,並將註釋作為 name 列
阿新 • • 發佈:2019-01-25
步驟一:
安裝MYSQL的ODBC驅動
Connector/ODBC 5.1.10 下載地址:
選擇win-32 MIS安裝包,進行直接安裝就可以了。
步驟二:
配置OBDC驅動連線
步驟三:
開啟PowerDesigner :
1)檔案->新建新模型
2)資料庫->connect to a Data Source
3)填寫資料庫連線資訊
4)開始逆向生成
確定後等待生成就好了。
可參考:http://blog.csdn.net/chamtianjiao/article/details/7258316
==========================================================================
將註釋和name列互相轉換如下:
在PowerDesigner中使用方法為:
PowerDesigner->Tools->Execute Commands->Edit/Run Scripts
將程式碼Copy進去執行就可以了,是對整個CDM或PDM進行操作
[vb] view plain copy print?- '程式碼一:將Name中的字元COPY至Comment中
- Option Explicit
- ValidationMode = True
- InteractiveMode = im_Batch
-
Dim mdl
- ' get the current active model
- Set mdl = ActiveModel
- If (mdl IsNothing) Then
- MsgBox "There is no current Model "
- ElseIfNot mdl.IsKindOf(PdPDM.cls_Model) Then
-
MsgBox "The current model is not an Physical Data model. "
- Else
- ProcessFolder mdl
- EndIf
- ' 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
- ForEach f In folder.Packages
- if not f.IsShortcut then
- ProcessFolder f
- end if
- Next
- end sub
另外在使用REVERSE ENGINEER從資料庫反向生成PDM的時候,PDM中的表的NAME和CODE事實上都是CODE,為了把NAME替換為資料庫中Table或Column的中文Comment,可以使用以下指令碼:
- '程式碼二:將Comment中的字元COPY至Name中
- Option Explicit
- ValidationMode = True
- InteractiveMode = im_Batch
- Dim mdl ' the current model
- ' get the current active model
- Set mdl = ActiveModel
- If (mdl IsNothing) Then
- MsgBox "There is no current Model "
- ElseIfNot mdl.IsKindOf(PdPDM.cls_Model) Then
- MsgBox "The current model is not an Physical Data model. "
- Else
- ProcessFolder mdl
- EndIf
- Private sub ProcessFolder(folder)
- OnErrorResumeNext
- 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
- ForEach f In folder.Packages
- if not f.IsShortcut then
- ProcessFolder f
- end if
- Next
- end sub