powerDesigner实现database到数据模型转换

最近有把项目数据库转换为数据模型的需要,其实之前做过多次,有点忘了,重新找了资料,整理一下,其中部分是从网上找的资源,写一下是为了方便自己后续查找

前提:使用powerdesigner工具,mysql数据库

一。建立数据连接

1.首先新建一个“PhysicalDataModel”类型的文件,然后点击“Database”->"Configure Connections",弹出窗口“Configure Data Connections”, 并选择"Connection Profiles"如下图所示: 





输入相关信息,ip,端口,数据库名,用户名,密码,最后选ok


点击确定

点击确定,即可生成对应的pdm模型

注意:若Power Designer找不到所选择的jar包或jar包不在CLASSPATH环境变量所指定的路径,将会报错:

Non SQL Error: Could not load class oracle.jdbc.OracleDriver

解决办法请参考一下地址:

地址一http://ema100.blog.sohu.com/281187861.html?qq-pf-to=pcqq.c2c

地址二: http://www.blogjava.net/amigoxie/archive/2013/10/13/404925.html



2.添加name列

Tools-->Display Perference-->选中左侧 “Table” ,再在右侧选中“Advanced”,进入“Customize Content”,选中“Columns”,选右上方的放大镜标志(搜索标志)--> "select Attributes"中选中code,并移动到最顶层,保存,发现就有了id和name列


3.转换codecomments,

ctrl+shift+x弹出窗口,输入如下脚本,或者保存到对应的目录下面,每次使用不用再查(脚本是借鉴别人的,很久以前保存的,忘了链接


脚本内容如下:

 

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

 ifcol.comment="" then

 else

col.name=  col.comment

 endif

 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



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值