powerdesigner逆向数据库

一、安装odbc

下载:https://dev.mysql.com/downloads/connector/odbc/

最新版odbc需要vs2022以后的redistribution,下载地址为:

X86
 
X64

二、配置odbc

到控制面板中配置“设置 ODBC 数据源(64 位)”,在“系统DSN”中点击“添加”

image

 

image

 上面给odbc取得名字为“LocalMySQL”。

三、powerdesigner逆向数据库

1、从“File”->“New Model”中新建物理模型

image

 从“Database”菜单下选择“connect”,建立和数据库的链接

image

 从弹出框中选择odbc数据源,也就是第一步建立的数据源,输入用户名和口令

image

 如果一切顺利,点击“Connect”会连接到数据库中

2、逆向数据库

image

 

image

 

image

 

image

 点击ok后就会将数据库中的表逆向到当前物理模型中。

四、将字段注释作为字段名

默认情况逆向的表字段“name”和“code”同名,我们希望将字段的comment作为name,显示更直观,我们可以按照下面的步骤进行:

‌1、打开目标 PDM 文件‌。

2、进入菜单:‌Tools → Execute Commands → Edit/Run Script‌。

3、将下方提供的 VBS 脚本粘贴到脚本编辑窗口。

 1 Option Explicit
 2 ValidationMode = True
 3 InteractiveMode = im_Batch
 4 
 5 Dim mdl
 6 Set mdl = ActiveModel
 7 
 8 If (mdl Is Nothing) Then
 9     MsgBox "There is no current Model"
10 ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then
11     MsgBox "The current model is not an Physical Data model."
12 Else
13     ProcessFolder mdl
14 End If
15 
16 Private Sub ProcessFolder(folder)
17     On Error Resume Next
18     Dim tab
19     For Each tab In folder.Tables
20         If Not tab.IsShortcut Then
21             If Len(tab.Comment) <> 0 Then
22                 tab.Name = tab.Comment
23             End If
24             Dim col
25             For Each col In tab.Columns
26                 If Len(col.Comment) <> 0 Then
27                     col.Name = col.Comment
28                 End If
29             Next
30         End If
31     Next
32 
33     Dim view
34     For Each view In folder.Views
35         If Not view.IsShortcut Then
36             If Len(view.Comment) <> 0 Then
37                 view.Name = view.Comment
38             End If
39         End If
40     Next
41 
42     Dim f
43     For Each f In folder.Packages
44         If Not f.IsShortcut Then
45             ProcessFolder f
46         End If
47     Next
48 End Sub

4、点击 ‌Run‌ 执行脚本。

执行后comment就会自动替换name

posted @ 2026-03-10 21:41  疯狗强尼  阅读(51)  评论(0)    收藏  举报