步骤一:
安装MYSQL的ODBC驱动
Connector/ODBC 5.1.10 下载地址:
http://dev.mysql.com/downloads/connector/odbc/5.1.html
选择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进行操作
-
-
-
- Option Explicit
- ValidationMode = True
- InteractiveMode = im_Batch
-
- Dim mdl
-
-
- 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)
- Dim Tab
- for each Tab in folder.tables
- if not tab.isShortcut then
- tab.comment = tab.name
- Dim col
- for each col in tab.columns
- col.comment= col.name
- next
- end if
- next
-
- Dim view
- for each view in folder.Views
- if not view.isShortcut then
- view.comment = view.name
- end if
- next
-
-
- Dim f
- For Each 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,可以使用以下脚本:
-
-
- Option Explicit
- ValidationMode = True
- InteractiveMode = im_Batch
-
- Dim mdl
-
-
- 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
- for each Tab in folder.tables
- if not tab.isShortcut then
- tab.name = tab.comment
- Dim col
- for each col in tab.columns
- if col.comment="" then
- else
- col.name= col.comment
- end if
- next
- end if
- next
-
- Dim view
- for each view in folder.Views
- if not view.isShortcut then
- view.name = view.comment
- end if
- next
-
-
- Dim f
- For Each f In folder.Packages
- if not f.IsShortcut then
- ProcessFolder f
- end if
- Next
- end sub