Step 1 :首先下载mysql-connector-odbc-3.51.27-win32.msi ,然后进行程序的安装。安装完毕之后打开控制面板,在打开管理工具,打开数据库源ODBC选择添加按钮选择对应的数据库(以Mysql为例),然后进行Mysql配置,相当于在Myeclipse下配置数据源一样的方法。
Step 2:打开powerdesigner。选择file--->reverse engineer--->database
Step 3:在弹出的对话框new physic data model里填写你自己的modelname,选择dbms为mysql5点击确定
Step 4:在弹出的 database reverse engineer selection 里选using a data source 并点击connect to a data source弹出connect to a data source对话框.
Step 5:选择data source 为odbc machine data source,并选择刚才配置好的mysql数据源输入用户密码点击connect返回到database reverse engineer options,点击确定。
Step 6:此时弹出,database reverse engineer对话框。选择要生成的表点击ok即可
最重要的地方
PowerDesigner中逆向工程将数据库中comment脚本赋值到PDM的name
执行方法:Open PDM -- Tools -- Execute Commands -- Run Script
Vb script代码
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
'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
Dim col 'running column
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