使用PowerDeSigner逆向生成Mysql数据库PDM图(带中文注释)
工具选型
相关资源,点击此处下载,提取码:x3xx。
- 使用的是15汉化版PowerDesigner
- mysql驱动选择的是mysql-connector-odbc-5.1.13-win32.msi,必须是32位
- Mysql只能是5.*版本,之前试过8.*版本,报错不兼容。
第一步、生成PDM图
-
打开PowerDesigner→文件→Reverse Engineer→Database
-
选择MySQL5.0
- 根据下图配置安装的Mysql5.0
- Data Source Name和Description随便填,下面的就填你的mysql数据库就OK,填完记得点test,这样database才会出现你的数据库。
- 一路确定,到该页面,选择刚刚配置的数据库。
- 一路确定,到该页面,勾选需要生成ER图的表
- 生成的ER图,表没有中文注释
第二步、 生成中文注释
- 需要修改VB代码,代码如下:
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
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
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
将代码粘贴到如图所示的地方。
终于出现中文注释了,但是,我的英文字段呢?!仿佛在逗我。请接着往下看
第三步、中英相聚
- 工具→显示参数选择
- 勾选code,并且置顶。
至此大功告成!!!!哈哈哈哈,有没有很激动?如果没搞出来,可以联系我。