1、通过数据库构建PDM
首先创建一个物理模型:file->new model
Model name:物理模型名称,可以自定义命名,或者使用默认名称
DBMS:物理模型所匹配的数据库
点击确定,生成一个物理模型
2、配置数据库连接
数据库配置支持三种方式:ODBC Machine、ODBC File Data Source、connection file
第一种方式,需要在自己的的计算机安装对应的驱动
控制面板->搜索odbc
根据自己安装的powerdesigner是32位或者64安装对应的驱动
下载对应的数据库连接驱动,然后安装,之后在该处点击添加,添加成功后到powerdesigner进行配置
Database->Configure connections
点击添加数据库连接
选择需要的驱动,点击下一页完成,配置数据库连接信息
数据库名称、数据库服务地址、端口、用户、密码,然后点击Test,测试是否成功
3、通过数据库生成PDM
Database->update model from database
勾选刚才配置的数据库连接
点击connect->确定,然后不同的数据库操作不同,pg数据库会有多个schema,勾选对应的表
点击ok
对应显示的列可以通过配置
tool->Display Preference
选择Table
勾选需要显示的列,调整顺序
配置之后展示情况
可以发现name与code一致,name并没有展示中文
双击模型,查看Comment列是否有值
如果该列没有值,进行sql修改
database->Edit current DBMS->Objects->colums
查看sql是否正确查出comment的值,可以进行对应的修改,如果提示权限不足,不允许修改,可以到对应的目录,进行文件夹的权限修改,添加“修改”权限,完成以后
tool->Execute Commands->edit/run script
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
将该脚本复制进去,点击执行
4、PDM生成数据库脚本
Database -> Generation Database
options选项根据对应的需求,选择是否需要生成删除表,用户等语句
成功生成了脚本