1.下载mysql的odbc驱动,注意下载32位的
下载地址:
http://mirrors.163.com/mysql/Downloads/Connector-ODBC/5.3/mysql-connector-odbc-5.3.12-win32.msi
下载后安装即可
如果PD为64为,odbc也需要下载64位的
PD64位下载:https://d2oa1bkv1sws6.cloudfront.net/PowerDesignerTrial/PowerDesigner16x64_Evaluation.exe
odbc64位下载:http://mirrors.163.com/mysql/Downloads/Connector-ODBC/5.3/mysql-connector-odbc-5.3.12-winx64.msi
odbc8.0驱动官网下载:https://dev.mysql.com/get/Downloads/Connector-ODBC/8.2/mysql-connector-odbc-8.2.0-winx64.msi
2.配置数据源
File --> Reverse Engineer --> Database
弹出新建物理数据库模型菜单
模型名任意填,点击确定
点击 using a data source后面的 连接数据源按钮
弹出窗口中点击configure
弹出窗口点击新增数据源
选择系统数据源,如果不可选中,也可选择用户数据源
找到mysql的数据源MySQL ODBC 5.3 Unicode Driver,并选中
点击完成
这里进行数据库连接配置,其中填写Data Source Name后面要用到
填完之后,点击Test测试一下数据库是否能连接成功
点击OK在列表可以看到已经有的数据源名称
回到连接数据源窗口,下拉可以选择刚才的数据源
选择aaa后点击connect ,然后点击确定
弹出逆向生成菜单
看上面这张图,先在All users中选择数据库名,然后点击右边的取消全选按钮,再选择要逆向生成的表,点击OK
生成之后Name一般是中文的,我们可以利用VBA脚本复制comment到Name
以下是从网上找的一段代码
代码:将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 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
在PowerDesigner中使用方法为:
PowerDesigner->Tools->Execute Commands->Edit/Run Scripts
将代码Copy进去执行就可以了,是对整个CDM或PDM进行操作
也可以将脚本保存起来,以备后续使用
原代码出处:https://www.cnblogs.com/cxd4321/archive/2009/03/07/1405475.html
常见安装报错:
1.myodbc5s.dll 找不到
解决方法:安装VC++运行库2013版
下载地址:https://www.microsoft.com/zh-CN/download/details.aspx?id=40784
推荐直接安装合集:Visual C++运行库合集(vc2005,vc2008,vc2010,VC2012运行库)下载v2021.01.10-VC运行库合集西西软件下载