Powerdesigner使用技巧

查看powerdesigner裏面一個pdm的總表數;

A: 右鍵 PDM模塊 →List Of →Tables,彈出List of Tables 對話框, 左側的序列號表明Table 的個數。html


 

powerdesigner 設置字段顯示comment註釋

選中準備編輯的表,【右鍵】->【Properties】->【Columns】->【Customize Columns and Filter】->【Comment】->【OK】 
或使用快捷鍵 
【右鍵】->【Properties】->【Columns】->【Ctrl+U】->【Comment】->【OK】 
這裏寫圖片描述
mysql

 


 PowerDesigner中Table視圖同時顯示Code和Name

PowerDesigner中Table視圖同時顯示Code和Name,像下圖這樣的效果:sql

邀月工做室

實現方法:Tools-Display Preference數據庫

邀月工做室

邀月工做室

邀月工做室

powerDesigner設置 name不自動等於code

從數據庫裏抽取了數據模型,爲了理清思路,須要將name改成中文名稱,可是pd自動將name填充爲code,能夠經過以下配置修改: post

選擇tools->general Options spa

選擇彈出窗口中的Dialog選項,將Name to Code mirroring 上的鉤去掉。.net

PowerDesigner 表名、字段大小寫轉換 

進入PowerDesigner,打開一個PDM,在菜單欄找到:Tools – Excute Commands – Edit/Run Script,或者直接按Ctrl+Shift+X調出腳本執行窗口,輸入下邊的代碼就能夠了。使用的是VBScript,語義比較容易理解,能夠根據本身的需求修改。3d

打開模型 Tools-->Execute Commands --> Edit/Run Scriptcode

UCase大寫 LCase小寫htm

輸入如下語句(根據實際狀況可作相應調整):

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

相關文章
相關標籤/搜索