PowerDesigner16.5逆向导出Mysql数据库模型并生成注释
安装ODBC驱动下载Connector/ODBC 8.0.28这里选择的32位的,因为powerdesigner是32位的,如果下载64的odbc会提示错误,这是一个坑安装的话直接一直下一步就行了配置ODBC连接ODBC安装完成之后是可以配置一个或多个连接的win10可以通过控制面板找到管理工具,然后打开ODBC数据源32位,参考我的是win11,通过搜索即可接下来按照如下图所示配置即可然后就可以
·
安装ODBC驱动
这里选择的32位的,因为powerdesigner是32位的,如果下载64的odbc会提示错误,这是一个坑
安装的话直接一直下一步就行了
配置ODBC连接
ODBC安装完成之后是可以配置一个或多个连接的
win10可以通过控制面板找到管理工具,然后打开ODBC数据源32位,参考
我的是win11,通过搜索即可
接下来按照如下图所示配置即可
然后就可以看到刚添加的odbc连接
Powerdesigner逆向导出
跟着图走
之后可以看到该数据源中的表(显示的所有库的表),我们过滤只要crm库中的表
之后就可以看到物理模型了
配置显示注释
这样就有表注释了
接下来展示字段注释,随便双击一张表,或者右键选择属性
这样就可以看到列注释了
但是此时在物理模型上并没有显示注释
Tools->Display Preferences->Table->Advanced...->Columns->List Columns
这时发现模型展示会多处一列,接下来我们只需要将注释替换到多出的这一列上
执行脚本命令
命令内容
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
运行之后即可看到我们最终要的效果
更多推荐
已为社区贡献1条内容
所有评论(0)