目录:
- 数据库的反向生成模型
- 模型的Cooment注释显示
步骤一:下载odbc驱动并进行安装:
(1)下载
mysql-connector-odbc-5.3.4-win32
注意:不管电脑是32位,还是64位,统一安装32位即可。
(2)安装




步骤二:odbcad32.exe添加数据源
找到C:WindowsSysWOW64目录下找到odbcad32.exe这个文件

双击打开,弹出ODBC数据源管理界面

点击添加按钮,在弹出的窗口中选中,安装好的驱动:

点击完成,弹出数据库信息创建窗体:

点击后Ok后,即可以看到新增加了选项:

配置完成。
步骤三:数据库导出为Sql脚本文件

步骤四:打开PowerDesigner软件,进行导入生成模型
A、选择菜单,导入数据源

B.选择数据库版本

C.点击添加Sql文件


D.点击确定后,即可进行转换,生成想要的数据库模型


步骤五,设置显示备注信息:
A、双击表,进入编辑模式,注意:表和列记得添加注释,如下图所示:

点击下图按钮:

B、勾选Comment的多选框

C、打开执行脚本编辑窗口


D、执行以下VBS脚本:
Option Explicit ValidationMode = True InteractiveMode = im_Batch Dim blankStr blankStr = Space(1) 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 = "" or replace(col.comment," ", "")="" Then col.name = blankStr blankStr = blankStr & Space(1) 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

E、执行后,即可发现注释已经正常现示:

步骤六:显示原字段名




点击Ok后,会弹出确认框,默认选择确定后即可看到效果:


步骤七:更改显示的顺序:

调整后效果:

数据库反向生成模型结束!