需求:原有數據庫是sqlserver,須要轉成postgresql數據庫,對應的er圖也要修改。遇到的問題:反向工程建好的table中的name都變成了code,丟失了原來的中文字段名稱
步驟:
1.打開原有er圖的pdm文件,選擇database -》generate database,在彈出的窗口中,directory選擇你導出的路徑。selection選擇默認便可
2.新建一個pdm(physical data model),file->reverse enginerr->database,選擇剛纔導出的sql語句。固然,sql語句要根據不一樣的數據庫修改爲對應的建表語句。
3.導入。
4.name變成了code,原來視圖中的中文註釋所有不顯示。
5.PowerDesigner->Tools->Execute Commands->Edit/Run Scripts
Option Explicit
ValidationMode = True
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
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="" 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
For Each f In folder.Packages
if not f.IsShortcut then
ProcessFolder f
end if
Next
end sub
固然,他的前提是你的common註釋中有你的字段的中文名,不然的話,請參考 http://miaoyue.iteye.com/blog/1223003 感謝貓月