Power Designer 15 数据库逆向工程
1. 破解及安装
下载地址
地址一:http://www.99d.com/down/173/486854.html
地址二:http://club.topsage.com/thread-2073507-1-1.html
1.安装Sysbase PowerDesigner 15.1。
2.拷贝pdflm15.dll到安装目录下。
3.重新启动计算机。
汉化(可选)
1.备份根目录下要汉化的文件。
2.拷贝汉化文件到安装目录下。
对于已有PD数据库文件,直接看第3步。
2. 对数据库进行反向工程
新建PDM(Physical Data Model).
1. 选择New Model(新模型),即打开创建模型选项窗口,如下图:
2. 选择Model types,在Model types的列表中选择Physical Data Model,最后选择Physical Diagram。在Model Name名称输入PDM的名称,DBMS选择数据库类型,选择”Share the DBMS definition。”
3. 单击”OK”,即完成PDM创建过程。
建立数据库连接
菜单”Database”à”Connect…”,弹出如下界面
没有ODBC数据源,则配置数据源。
(SQL2005时注意)在配置ODBC的时候,连点两个“下一步”按钮后,在第3个页面中将“更改默认的数据库为”复选框选中,并从数据库列表中选中你要Reverse的数据库,就会出现这个问题。如果取消“更改默认的数据库为”复选框的选中状态,问题解决!!!
而MSSQL2000时需要选中,而且要指定默认的数据库。
选择”ODBC machine data source”,点击”Configure”(配置过程省略)
对数据库进行反向工程
数据库连接建立完成后选择”Database”à”Update Model from Database…”
点击确定。
在MSSQL2005中,由于没有默认数据库,需要选择数据库。
在此对话框选择注意选择需要的视图、触发器和存储过程。
点击”OK”则对数据库进行反向工程。
3. 修改数据库信息
数据库
双击左侧的PDM,弹出如下对话框,修改数据库信息。
数据表
字段
设置主键(Primary)在自定义列性息中,选择Primary。
设置索引(Index)
设置关键字(Key)
修改字段默认值
在上图中,选择需要修改默认值的列,点击第一个小图标(Properties),在Standard Checks页中的Default输入默认值。
自定义列信息
在上图中,点击倒数第二个小图标(customize Column and Filter).
4. Report的生成环境
有2中方法生成报表,我们使用第二种方法输出报表。
新建一个报表
菜单Report--àReport…
点击第二个图标New Report.
输入报表名称,语言栏选择Simplified Chinese,点击OK,开始设计新报表。
4.如下图:我们左右2个区,Aavailable区域中选择你想要在WORD文档中展示的东东,这里我们选择List of Tables,和List of Table Columns[数据表格信息],当然你也可以加别的一些元素。
完成报表设计之后,保存。
在主窗口菜单选择,Report--àGenerate Report…
设置好相应设置,点击OK。
就生成了中文的RTF数据库设计文档了。
从报表模板中创建报表
将报表模板MyReportTemp.rtp,拷贝到安装路径下的\Resource Files\Report Templates目录下。菜单Report--àGenerate Report--àReport Template,选择报表模板,做好相应设置,点击OK。
5. 从PDM中创建和修改数据库
创建数据库
菜单Database--àGenerater Database。
注意问题,在Option页中,去掉User的选择框。(因为用的默认用户dbo已存在,而且不能删除)
修改数据库
菜单Database--àUpdate Model Change to Database…
选号设置,生成修改数据库脚本,执行脚本修改数据库。
6. 问题
中文报表模板输出RTF有乱码
选择中文模板,右键选择属性(Properties),在RTF Format页中的Template选择None.
PD不支持SQL Server 2005,怎么办
前两天试用PD12的时候遇到一个奇怪的事情,不知道算不算是PD12的BUG。事情的经过是这样的:
后台数据库从SQL2000升级到SQL Server 2005(简体中文版),由于PD11不支持SQL2005,所以从Sybase下载了PD12的试用版,结果发现PD12不能Reverse数据库!
PD能够作反向工程的,有两个地方,(1)File - Reverse Engineer - Database,这个功能主要用于将数据库结构反向工程为PDM设计文档,一般只用一次,以后的设计变更就直接在PDM上做了。(2)打开一个PDM之后,点击菜单Database - Reverse Engineer Database,这个功能主要是用来比较PDM文档与实际数据库之间的结构上的差异,便于两者同步。
现在数据库换成SQL2005、PD换成V12以后(Sybase网站上有两个版本,12.0和12.1,我都试了,都有相同的毛病),Reverse的时候都提示“Unable to list Tables”,不能列出SQL2005中有哪些用户表!直接后果就是无法比较PDM设计文档和SQL2005数据库的结构差异!
胖子刘
2006.10.16
====================================================================
在一个非常机缘巧合的情况下,我找到了问题的解决办法。
上面的问题是怎么产生的呢?
在配置ODBC的时候,连点两个“下一步”按钮后,在第3个页面中将“更改默认的数据库为”复选框选中,并从数据库列表中选中你要Reverse的数据库,就会出现这个问题。
如果取消“更改默认的数据库为”复选框的选中状态,问题解决!!!
同样的操作用在PD11和SQL2000环境下就没问题,所以当这对搭档升级为PD12和SQL2005之后,如果还沿用以前的习惯就会出错。不知道算不算是BUG!!!
前车之鉴,与大家共享。
胖子刘
2006.10.16
7. 其他技巧
取消name和code联动
在修改name的时候,code的值将跟着变动,很不方便。修改方法:PowerDesign中的选项菜单里修改,在[Tool]-->[General Options]->[Dialog]->[Operating modes]->[Name to Code mirroring],这里默认是让名称和代码同步,将前面的复选框去掉就行了。如图:
Name和Comment关联
在使用PowerDesigner对数据库进行概念模型和物理模型设计时,一般在NAME或Comment中写中文,在Code中写英文。Name用来显 示,Code在代码中使用,但Comment中的文字会保存到数据库Table或Column的Comment中,当Name已经存在的时候,再写一次 Comment很麻烦,可以使用以下代码来解决这个问题:
· 代码一:将Name中的字符COPY至Comment中
· '******************************************************************************
'* File: name2comment.vbs
'* Purpose: Database generation cannot use object names anymore
' in version 7 and above.
' It always uses the object codes.
'
' In case the object codes are not aligned with your
' object names in your model, this script will copy
' the object Name onto the object Comment for
' the Tables and Columns.
'
'* Title:
'* Version: 1.0
'* Company: Sybase Inc.
'******************************************************************************
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
' This routine copy name into comment for each table, each column and each view
' of the current folder
Private sub ProcessFolder(folder)
Dim Tab 'running table
for each Tab in folder.tables
if not tab.isShortcut then
tab.comment = tab.name
Dim col ' running column
for each col in tab.columns
col.comment= col.name
next
end if
next
Dim view 'running view
for each view in folder.Views
if not view.isShortcut then
view.comment = view.name
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
--------------------------------------------
另外在使用REVERSE ENGINEER从数据库反向生成PDM的时候,PDM中的表的NAME和CODE事实上都是CODE,为了把NAME替换为数据库中Table或Column的中文Comment,可以使用以下脚本:
· 代码二:将Comment中的字符COPY至Name中
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
-----------------------------------------------------------------------
以上两段代码都是VB脚本,在PowerDesigner中使用方法为:
PowerDesigner->Tools->Execute Commands->Edit/Run Scripts
将代码Copy进去执行就可以了,是对整个CDM或PDM进行操作
8. 缺点
1.由于只是建模工具,不能生成默认数据。