PowerDesigner根據sql檔案生成表模型
經常要在PD中建表, 但是一個一個複製又比較無聊, 使用sql檔案逆向生成
-
拼接建表語句, 利用程式+excel,+Editplus 很容易拼接出來(commen要加: 對應pd.table中name屬性)
-
建表, 用PLSQL匯出sql檔案, tools–export user objects–選中表剛建的表–export
-
記事本開啟匯出的.sql檔案
a. 將sql檔案中表前面 表空間+"." 全部替換為空串
b. 另存為(解決中文亂碼) -
pdm建模型
此時name(左邊)是英文
執行下面指令碼, 將name改為comment內容, 點選Run
Option Explicit
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
'This routine copy name into code 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
if len(tab.comment) <> 0 then
tab.name = tab.comment
end if
On Error Resume Next
for each col in tab.columns
if len(col.comment) <>0 then
col.name =col.comment
end if
On Error Resume Next
next
end if
next
end sub
改table背景顏色
在這裡插入圖片描述