最近用powerDesinger遇到一些小問題,遇到好幾次同樣的問題了,寫在這裡,以備查用:
--------------------------------------------------------------------------------------------------
sql語句中表名與欄位名前的引號去除:
開啟cdm的情況下,進入Tools-Model Options-Naming Convention,把Name和Code的標籤的Charcter case選項設定成Uppercase或者Lowercase,只要不是Mixed Case就行!
或者選擇Database->Edit current database->Script->Sql->Format,有一項CaseSensitivityUsingQuote,它的 comment為“Determines if the case sensitivity for identifiers is managed using double quotes”,表示是否適用雙引號來規定標識符的大小寫, 可以看到右邊的values預設值為“YES”,改為“No”即可!
或者在開啟pdm的情況下,進入Tools-Model Options-Naming Convention,把Name和Code的標籤的Charcter case選項設定成Uppercase就可以!
在修改name的時候,code的值將跟著變動,很不方便
修改方法:PowerDesign中的選項菜單裡修改,在[Tool]-->[General Options]->[Dialog]->[Operating modes]->[Name to Code mirroring],這裡預設是讓名稱和代碼同步,將前面的複選框去掉就行了。
由pdm產生建表指令碼時,欄位超過15字元就發生錯誤(oracle)
原因未知,解決辦法是開啟PDM後,會出現Database的功能表列,進入Database - Edit Current DBMS -script-objects-column-maxlen,把value值調大(原為30),比如改成60。出現表或者其它對象的長度也有這種錯誤的話都可以選擇對應的objects照此種方法更改!
或者使用下面的這種方法:
產生建表指令碼時會彈出Database generation提示框:把options - check model的小勾給去掉,就是不進行檢查(不推薦)!
或者可以修改C:\Program Files\Sybase\PowerDesigner Trial 11\Resource Files\DBMS\oracl9i2.xdb檔案
修改好後,再cdm轉為pdm時,選擇“Copy the DBMS definition in model”把把這個資源檔拷貝到模型中。
由CDM產生PDM時,自動產生的外鍵的重新命名
PDM Generation Options->Detail->FK index names預設是%REFR%_FK,改為FK_%REFRCODE%,其中%REFRCODE%指的就是CDM中Relationship的code!另外自動產生的父欄位的規則是PDM Generation Options->Detail->FK column name template中設定的,預設是%.3:PARENT%_%COLUMN%,可以改為Par%COLUMN%表示是父欄位!
建立一個表後,為何檢測出現Existence of index的警告
A table should contain at least one column, one index, one key, and one reference.
可以不檢查 Existence of index 這項,也就沒有這個警告錯誤了!
意思是說沒有給表建立索引,而一個表一般至少要有一個索引,這是一個警告,不用管也沒有關係!
如何防止一對一的關係產生兩個引用(外鍵)
要定義關係的支配方向,占支配地位的實體(有D標誌)變為父表。
在cdm中雙擊一對一關聯性->Detail->Dominant role選擇支配關係
修改報告模板中一些術語的定義
即檔案:C:\Program Files\Sybase\PowerDesigner Trial 11\Resource Files\Report Languages\Chinese.xrl
Tools-Resources-Report Languages-選擇Chinese-單擊Properties或雙擊目標
修改某些對象的名稱:Object Attributes\Physical Data Model\Column\
ForeignKey:外鍵
Mandatory:為空白
Primary:主鍵
Table:表
用尋找替換,把“表格”替換成“表”
修改顯示的內容為別的:Values Mapping\Lists\Standard,添加TRUE的轉化列為是,FALSE的轉化列為空白
另外Report-Title Page裡可以設定標題資訊
PowerDesigner11中批量根據對象的name產生comment的指令碼
'******************************************************************************
'* File: name2comment.vbs
'* Purpose: Database generation cannot use object names anymore
' in version 7 and above.
' It always uses the object codes.
'
' In case the object codes are not aligned with your
' object names in your model, this script. will copy
' the object Name onto the object comment for
' the Tables and Columns.
'
'* Title: 把對象name拷入comment屬性中
'* Version: 1.0
'* Author:
'* 執行方法:PD11 -- Open PDM -- Tools -- Execute Commands -- Run Script
'******************************************************************************
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
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
PowerDesigner 產生SQL的Existence of refernce錯誤問題
現象:用PowerDesigner產生SQL語句時,提示Existence of refernce錯誤。
原因:該表沒有與其他表的關聯(如外鍵等),而PowerDesigner需要存在一個refernce才能產生SQL.
解決方案:
在工具列空白處右鍵開啟Palette面板,選中Link/Extended Dependency 按鈕,然後在提示出錯的表上添加到自己的Dependency。
重建SQL,你將發現剛才提示的錯誤沒有了,問題解決。
利用PowerDesigner批量產生測試資料
主要解決方案:
A:在PowerDesigner 建表
B:然後給每一個表的欄位建立相應的摘要檔案
步驟如下:
Model->Test Data Profiles配置每一個欄位摘要檔案General:輸入Name、Code、
選擇Class(數字、字元、時間)類型
選擇Generation Source: Automatic、List、ODBC、File Detail:配置欄位相關資訊
所有欄位摘要檔案配置完成後雙擊該表->選擇欄位->Detail->選擇Test Data Parameters 摘要檔案如果欄位值與其它欄位有關係在: Computed Expression 中輸入計算資料行--產生測試資料:
DataBase->Generation Test Data->
選擇:Genration 類型(Sript、ODBC)
Selection(選擇要產生的表)
Test Data Genration(Default number of rows 產生記錄行數)