1.下载mysql的odbc驱动,注意下载32位的
下载地址:
下载后安装即可
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进行操作
也可以将脚本保存起来,以备后续使用