目录
附:PowerDesigner16.5 安装包地址
链接:https://pan.baidu.com/s/1-JC2QF727OVW7U1zdiGd3A
提取码:zam6
1、建立数据库模型
打开 PowerDesigner ,点击 "New Model" - Model types - Physical Data Model - Physical Diagram

点击“确定”

2、进行数据库连接配置:
Database - Connnect,

会弹出如下页面,如果首次连接,则需要进行配置,否则直接选择配置好的文件,输入用户ID密码登录。


配置请参考下图:

(JDBC 连接如果是本地的话,就把图中的 ip,改为localhost)
配置完成可以先做一下 test 连接,点击上图左下角“Test Connection”,如果失败请参考PowerDesigner连接远程mysql数据库连接不上 第2篇。
3、获取数据模型

弹出如下图,选择我们的连接配置文件

点击“确定”,可以查看到如下信息:

点击“OK”,展示出数据模型图
默认展示,ER图默认只展示id,type,如果想要展示出中文注释,则要改一些配置。
Tools - Display Preferences

将【Code】 选中,并移动到最上边,完成。此时我们的 ER 图已经变化。但是却展示的俩列 ID,此时还要执行vbscript 脚本就可以展示中文了。执行路径【Tools - Execute Command - Run Script】或者快捷键【Ctrl + Shift + X】
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
Run 执行之后,字段中英文都可以展示出来。

具体表的信息
要想只看具体某一张表的信息,可以table - tablename - 右键“properties” - columns ,
还想要看到中文注释信息则如下图操作:


本文详细介绍如何使用PowerDesigner 16.5建立数据库模型,包括数据库连接配置、获取数据模型及展示中文注释的过程。通过步骤指导,帮助读者掌握PowerDesigner的核心功能。
2587

被折叠的 条评论
为什么被折叠?



