'*****************************************************************************
dim model 'current model
set model = ActiveModel
If (model Is Nothing) Then
MsgBox "There is no current Model"
ElseIf Not model.IsKindOf(PdPDM.cls_Model) Then
MsgBox "The current model is not an Physical Data model."
Else
ProcessTables model
End If
'*****************************************************************************
'函数:ProcessTables
'功能:递归遍历所有的表
'*****************************************************************************
sub ProcessTables(folder)
'Process tables in the model
dim table
for each table in folder.tables
if not table.IsShortCut then
ProcessTable table
end if
next
'Recursively
dim subFolder
for each subFolder in folder.Packages
ProcessTables subFolder
next
end sub
'** **************************************************** ************************
'Function: ProcessTable
'Function: Traverse all fields of the specified table, if the field is a primary key but not a foreign key, then Set to Identity
'********************************************** ********************************
sub ProcessTable (table)
dim col
for each col in table.Columns
'Set to Identity (self-increasing type) for fields that are primary keys and not foreign keys
if col.Primary and not col.ForeignKey and instr(lcase(col.datatype),"integer") > 0 then
col.Identity = true
end if
next
end sub
Save it as the file A_SetIdentity.vbs and put it in the vb scripts folder in the installation directory
In powerdesigner's pdm, ctrl+shift+x opens the menu bar of the run script dialog box and selects open file to find A_Setidentity.vbs to execute
70EF4733-6445-4BAC-9F92-AD8A086A5398|From:http://www.cnblogs.com/xuejianxiyang/p/8926694.html