PowerDesigner反向Mysql
基础说明
软件版本
PowerDesigner15 + Mysql
前期准备
- 明确PowerDesigner15 是64还是32位?
- 安装Mysql的ojdbc驱动
安装Mysql的ojdbc驱动
下载驱动 Mysql的Odbc官网下载地址 ,安装
注意选择对应的数据库版本和PowerDesigner15相同位数的驱动包
反向工程
使用以管理员身份运行PowerDesigner15
填写对应的数据库配置信息,点击Test进行测试,测试成功后,点击“OK”
在该页面可以通过user筛选具体的库及表,点击“OK”即可
将备注设置作为名称使用
可参考 PowerDesigner批量将name添加到comment里面的方法,进行修改后
'如果comment为空,则填入name;如果不为空,则保留不变。
Option Explicit
ValidationMode = True
InteractiveMode = im_Batch
Dim system, file
Set system = CreateObject("Scripting.FileSystemObject")
Dim ForReading, ForWriting, ForAppending '打开文件选项
ForReading = 1 ' 只读
ForWriting = 2 ' 可写
ForAppending = 8 ' 可写并追加
'打开文本文件
Set file = system.OpenTextFile("C:\pdcomment.txt", ForWriting, true)
'判断当前model是否物理数据模型
Dim mdl
Set mdl = ActiveModel
If (mdl Is Nothing) Then
MsgBox "处理对象无模型"
ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then
MsgBox "当前模型不是物理数据模型"
Else
ProcessFolder mdl,file
End If
file.Close
'******************************************************************************
Private sub ProcessFolder(folder,file)
Dim tab 'running table
for each tab in folder.tables
if not tab.isShortcut then
if not trim(tab.comment)="" then
tab.name = tab.comment
end if
Dim col
for each col in tab.columns
if not trim(col.comment)="" then
col.name = col.comment
end if
next
end if
next
end sub
在运行时,如果表名称的备注存在重复的备注,会造成异常,需要手动修改一下备注即可