powerdesigner逆向工程生成PDM时的列注释解决方案

步骤:

1、创建DBMS

  Powerdesigner界 面-tools-Resources-DBMS,点击左上角的New,选择copy from templete,如果你的数据库是sql server 2005,选择系统自带的SQL server 2005,如果是sql server 2008,选择系统自带的sqlsv2k8.xdb。本例中是sql server 2008 r2,故选择 sqlsv2k8.xdb,起一个新名字,如 SQL2008_Mod_201105。

邀月工作室

2、建立数据源,逆向生成测试,顺利成功!

邀月工作室

此时再生成数据库脚本时,会自动将Comment中的中文注释带入到脚本中。

邀月工作室

美中不足的是Name还是英文 ,在一个包中查看表时,感觉怪怪的。

有两个解决办法:

3-1、改进脚本

Powerdesigner界面-Database-Edit Current DBMS

如下: 本文以sql server 2008为例,sql server 2005类同。 )

将表的Name换为Comment

邀月工作室

将列的Name换为Comment

邀月工作室

此时生成的效果最为理想。

邀月工作室

3-2、利用vbs脚本完成。

Sybase安装路径/VB Scripts 下新建Comments2Name.vbs,内容如下:

  1. Option Explicit  
  2. ValidationMode = True  
  3. InteractiveMode = im_Batch  
  4. Dim mdl 'the current model  
  5. 'get the current active model  
  6. Set mdl = ActiveModel  
  7. If (mdl Is NothingThen  
  8. MsgBox "There is no current Model"  
  9. ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then  
  10. MsgBox "The current model is not an Physical Data model."  
  11. Else  
  12. ProcessFolder mdl  
  13. End If  
  14. 'This routine copy name into code for each table, each column and each view  
  15. 'of the current folder  
  16. Private sub ProcessFolder(folder)  
  17. Dim Tab 'running table  
  18. for each Tab in folder.tables  
  19. if not tab.isShortcut then  
  20. if len(tab.comment) <> 0 then  
  21. tab.name = tab.comment  
  22. end if  
  23. On Error Resume Next  
  24. Dim col 'running column  
  25. for each col in tab.columns  
  26. if len(col.comment) <>0 then  
  27. col.name =col.comment  
  28. end if  
  29. On Error Resume Next  
  30. next  
  31. end if  
  32. next  
  33. end sub  

在生成的PDM中,Powerdesigner界面-tools-Execute Cmmands-Edit/Run Scripts 在打开的界面中,左上角,选择打开,Ctrl+O,选取刚才的 Comments2Name.vbs,并Run,效果同上。

邀月工作室

邀月工作室

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值