需求:原有数据库是sqlserver,需要转成postgresql数据库,对应的er图也要修改。遇到的问题:反向工程建好的table中的name都变成了code,丢失了原来的中文字段名称
步骤:
1.打开原有er图的pdm文件,选择database -》generate database,在弹出的窗口中,directory选择你导出的路径。selection选择默认即可
2.新建一个pdm(physical data model),file->reverse enginerr->database,选择刚才导出的sql语句。当然,sql语句要根据不同的数据库修改成对应的建表语句。
3.导入。
4.name变成了code,原来视图中的中文注释全部不显示。
5.PowerDesigner->Tools->Execute Commands->Edit/Run Scripts
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
当然,他的前提是你的common注释中有你的字段的中文名,否则的话,请参考
http://miaoyue.iteye.com/blog/1223003
感谢猫月
分享到:
相关推荐
powerdesigner逆向工程导入mysql脚本生成PDM带全注释
本文将深入探讨如何使用PowerDesigner进行MySQL数据库的逆向工程,并解决逆向工程过程中可能出现的没有注释的问题。 首先,让我们了解什么是逆向工程。逆向工程,也称为数据库反向设计,是指从已有的数据库中提取其...
标题中提到的问题,即"PowerDesigner逆向工程时,将表字段的comment转换为PDM的name",可以通过编写和执行自定义脚本来实现。以下是这个过程的详细步骤: 1. 打开PowerDesigner中的PDM模型。 2. 进入"Tools"菜单,...
- 在PowerDesigner中使用Database菜单下的Import SQL Script功能,导入脚本文件。 - 脚本执行完成后,即可生成对应的PDM。 #### 六、案例分析 以下是一个简单的SQL脚本示例,用于创建两个表:“class”和“student...
- **约束和索引**:在迁移过程中,可能会丢失某些数据库结构,如主键和外键,需要在目标数据库中手动恢复。 - **性能考虑**:大规模数据迁移可能需要较长的时间,应考虑数据量、网络速度和服务器性能等因素。 - **...