Powerdesigner使用技巧

查看powerdesigner里面一个pdm的总表数;

A: 右键 PDM模块 →List Of →Tables,弹出List of Tables 对话框, 左侧的序列号代表Table 的个数。


 

powerdesigner 设置字段显示comment注释

选中准备编辑的表,【右键】->【Properties】->【Columns】->【Customize Columns and Filter】->【Comment】->【OK】 
或使用快捷键 
【右键】->【Properties】->【Columns】->【Ctrl+U】->【Comment】->【OK】 
这里写图片描述

 


 PowerDesigner中Table视图同时显示Code和Name

PowerDesigner中Table视图同时显示Code和Name,像下图这样的效果:

邀月工作室

实现方法:Tools-Display Preference

邀月工作室

邀月工作室

邀月工作室

powerDesigner设置 name不自动等于code

从数据库里抽取了数据模型,为了理清思路,需要将name改为中文名称,但是pd自动将name填充为code,可以通过如下配置修改: 

选择tools->general Options 

选择弹出窗口中的Dialog选项,将Name to Code mirroring 上的钩去掉。

PowerDesigner 表名、字段大小写转换 

进入PowerDesigner,打开一个PDM,在菜单栏找到:Tools – Excute Commands – Edit/Run Script,或者直接按Ctrl+Shift+X调出脚本执行窗口,输入下边的代码就可以了。使用的是VBScript,语义比较容易理解,可以根据自己的需求修改。

打开模型 Tools-->Execute Commands --> Edit/Run Script

UCase大写 LCase小写

输入以下语句(根据实际情况可做相应调整):

Option Explicit  
ValidationMode = True  
InteractiveMode = im_Batch  
Dim mdl ' 当前模型  
' 获取当前模型  
Set mdl = ActiveModel  
If (mdl Is Nothing) Then  
   MsgBox "没有打开一个模型" 
ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then  
   MsgBox "当前模型不是一个PDM" 
Else  
'调用处理程序  
   ProcessFolder mdl  
End If    
'调用的处理程序  
Private sub ProcessFolder(folder)  
   Dim Tab '要处理的表  
   for each Tab in folder.Tables  
    ' if not Tab.isShortcut then  
        ' Tab.code = tab.name  
        '表名处理,前边添加前缀,字母小写  
        Tab.name=  UCase(Tab.name)  
        Tab.code= UCase(Tab.code)  
         Dim col ' 要处理的列  
         for each col in Tab.columns  
            '列名称和code全部小写,大写诗UCase  
            col.code= UCase(col.code)  
            col.name= UCase(col.name)  
         next  
      'end if 
   next    
' 处理视图  
'  Dim view 'running view  
'   for each view in folder.Views  
   '   if not view.isShortcut then  
       '  view.code = view.name  
    '  end if 
  ' next     
   ' 递归进入 sub-packages  
   Dim f ' sub  folder  
   For Each f In folder.Packages  
      if not f.IsShortcut then  
         ProcessFolder f  
      end if 
   Next  
end sub 

PowerDesigner中NAME和COMMENT的互相转换

使用说明: 在【Tools】-【Execute Commands】-【Edit/Run Script】 下。输入下面你要选择的语句即可,也可以保存起来,以便下次使用,后缀为.vbs。

 需要注意的问题是:运行语句时必须在Module模式下,如果是导出报表时执行会出现错误提示。

1.Name转到Comment注释字段。一般情况下只填写NAME,COMMENT可以运行语句自动生成。

将该语句保存为name2comment.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 code 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  
  
Dim col 'running column  
for each col in tab.columns  
If (col.comment="") Then '已存在的comment则不更新  
col.comment= col.name  
end if  
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中,comment2name.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    
  
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  

生成主键和自增列

Oracle版本

总的来说需要建立序列,并把这个序列赋给某一列,重建触发器即可。 

第一步,打开PD,新建一个PDM文档,然后新建一个表,如图所示:

第二步,创建一个序列。在【Model】-【Sequence】打开序列列表窗口,新建一个序列。然后打开序列的属性设置项【physical Options】,进行如下设置,点击确定,序列建立完毕。

第三步,将刚刚创建的序列应用到表的主键列中。如图所示:点击确定,此时还没结束,关键一步,要重建触发器。

第四步:重建触发器,在【Tools】下如图,点击

点击确定,至此,自动创建了一个触发器,把序列的值添加到主键中。 

MySql版本 

选中UserId单击右键选择Properites 
这里写图片描述 
将Identity选中即可 
这里写图片描述

也可以通过下图让自增长属性显示出来。

powerdesigner设置mysql唯一键,非主键

员工表如下,先将id设置主键:


现在将"员工id"设置唯一约束:
1,切换到"Keys",发现已经存在一个Key1,这个是刚刚新增主键id。在Key1下发空行出,点击会新增一个Key2:


2,双击Key2,在Constraint name输入唯一约束的名字,一般命名方式:UNQ_表名_字段名


3,切换到Columns,选择员工id字段,点击OK:


4,这一步很关键:切换到MySQL,选择Unique key(如果不选择此项,员工id会和id一起成为联合主键)


生成后的表结构如下面:

PowerDesigner使用:创建索引

1. 创建一个学生表(Student),包含学号Sno,班级号Sclass,姓名Sanem。  

PowerDesigner使用:[3]创建索引

2. 下面为班级号创建索引。选择Indexes标签页,然后点击新增一行来添加索引,然后点击应用保存。

 

 

PowerDesigner使用:[3]创建索引

 

3. 打开索引的属性视图进行修改索引信息,将其名称改为index_class

PowerDesigner使用:[3]创建索引

4. 在索引的属性视图选择columns标签页,添加索引列。选择班级号Sclass列。然后点击OK来确认添加。

PowerDesigner使用:[3]创建索引

5. 可通过索引列的Sort属性来修改索引列的排序方式。

PowerDesigner使用:[3]创建索引

6. 在第三步 属性视图 中,可通过页面下方的Unique属性控制索引是否为唯一索性,通过Cluster属性控制索引是否为簇索引。

PowerDesigner使用:[3]创建索引

7. 预览下创建索引脚本如下

PowerDesigner使用:[3]创建索引

参考资料

http://www.cnblogs.com/netsql/archive/2010/05/24/1742734.html

https://www.cnblogs.com/ShaYeBlog/p/4067884.html

https://blog.csdn.net/swazer_z/article/details/51197823

转载于:https://www.cnblogs.com/junzi2099/p/8308992.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值