PowerDesigner使用小总结

前言

总结powerdesigner使用技巧,如取消name和code的联动,去掉双引号等,方便中国用户使用

自己使用的PowerDesigner版本为16.5

基础

  • 去掉SQL中的双引号

    按照图片圈出来的部分操作

    3bec83a4ce95df6bd5fc377c967f50315e6.jpg

    修改配置

    8bb1762cb3d92db60635686d29dc1e02cf3.jpg

  • 取消name和code的联动

    依次选择:Tools->General Operations

    出现下图界面,选择Dialog,将图中的复选框选择取消掉

    26abde2debd8ca49a377aeda4443b0c1a21.jpg

  • 在表中显示name和code

    依次选择:Tools->Display Preferences

    出现下图界面,选择Table,点击Advanced

    f76797d47ae4e9e72b4d4af0a15cf7fa259.jpg

    根据图中圈出来的部分最终确定显示的列和先后顺序

    75b79a0168b147319b5f0e7eb59485581f6.jpg

    最终的显示结果如下:

    25b27093b1190a72a3bb7b1aafcabfd83f9.jpg

  • 创建的外键关联不添加物理连接

        现在通常做数据库设计的时候不再需要外键,因为外键会严重降低性能,但powerdesigner的默认配置在使用外键时会自动添加物理连接,而且删除外键的时候会自动删掉列,这让人很痛苦,后来发现用两种方式可以避免此问题

        1.使用外键-reference(实现),但不创建连接

            PowerDesigner中配置外键关系时,如果要删除配置的外键关系,默认设置会一同删除外键列. 要更改此设置,需在菜单栏tools中打开Model Options,在Model Settings中点击Reference, 然后把"Auto-migrate columns"这个checkbox的勾去掉,即可

        2.使用追溯-traceability link(虚线),不会生成外键

            这样可能以往在视觉上效果不一样,但我建议可以这样做,避免别人误认为导出来的脚本是含有外键的

高级

  • 将name字段值放到comment

    中国用户为了方便理解,在name字段通常使用中文,最终还希望将中文添加到备注当中去。下面的操作步骤非常重要

    1.设计表的时候先不要去添加任何字段的备注,否则一会儿执行脚本将name转换为字段的时候会将之前的备注全部清除掉

    2.执行脚本

    3.添加个性化的备注,比如约定枚举值等

    版本一:name覆盖comment

        脚本内容如下:

'******************************************************************************
'* File:     name2comment.vbs
'* Title:    Name to Comment Conversion
'* Model:    Physical Data Model
'* Objects: Table, Column, View
'* Author:   steveguoshao
'* Created: 2013-11-29
'* Mod By:   
'* Modified: 
'* Version: 1.0
'* Memo:     Modify from name2code.vbs
'******************************************************************************
​
​
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

    版本2:如果comment不为空,则用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 

'   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
                     if  trim(tab.comment)="" then'如果有表的注释,则不改变它.如果没有表注释.则把name添加到注释里面.
                        tab.comment   =   tab.name
                     end if  
                  Dim   col   '   running   column    
                  for   each   col   in   tab.columns   
                        if trim(col.comment)="" then '如果col的comment为空,则填入name,如果已有注释,则不添加;这样可以避免已有注释丢失.
                           col.comment=   col.name   
                        end if 
                  next    
            end   if    
      next    
  
      Dim   view   'running   view    
      for   each   view   in   folder.Views    
            if   not   view.isShortcut and trim(view.comment)=""  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

将上面的内容保存到name2comment.vbs中

进入脚本执行界面

31626a400995ee124d60d6990f542931122.jpg

打开选择脚本窗口

c83423547df8bb57feeb1fbb1d8bece2e3a.jpg

选择并执行脚本

d315b0ab117313e0adce98cf9c583456d5c.jpg

然后查看你的SQL脚本

 

 

转载于:https://my.oschina.net/u/3049601/blog/1920174

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值