泰兴网站建设,网站建设做网站,矿业公司网站源码,做免费外贸网站powerdesigner 使用 文章目录powerdesigner 使用1. 建立数据库表模型2. 脚本统一修改表结构#xff08;赋值默认字段、统一删除、统一修改#xff09;2.1.统一添加默认字段#xff1a;2.2.统一删除字段#xff1a;2.3.统一修改表名称#xff1a;2.4. 统一修改字段属性赋值默认字段、统一删除、统一修改2.1.统一添加默认字段2.2.统一删除字段2.3.统一修改表名称2.4. 统一修改字段属性2.5.其他函数1. 建立数据库表模型
1.1.创建模型并选择数据库类型
1.2 建立表
1.3.修改表名称
1.4.编辑表结构 1.5.编辑索引 1.6.查看sql语句
2. 脚本统一修改表结构赋值默认字段、统一删除、统一修改 tools - execute commands - edit/ run Scripe 打开窗口输入vb脚本命令
2.1.统一添加默认字段 对于需要排除在外的表可添加在下面代码中 if instr(,Ex1,Ex2,,,CurrentObject.Code,)0 then exit sub Option Explicit
ValidationMode True
InteractiveMode im_BatchDim mdl
Set mdl ActiveModel
If (mdl Is Nothing) ThenMsgBox There is no Active Model
ElseListObjects(mdl)
End IfPrivate Sub ListObjects(fldr) output Scanning fldr.codeDim obj For Each obj In fldr.childrenTableSetComment objNextDim f For Each f In fldr.Packages ListObjects fNext
End SubPrivate Sub TableSetComment(CurrentObject)if not CurrentObject.Iskindof(cls_Table) then exit subif instr(,Ex1,Ex2,,,CurrentObject.Code,)0 then exit subif not CurrentObject.isShortcut thenDim col Dim numdim create_user_iddim create_timedim update_user_iddim update_timedim is_deletecreate_user_id1update_user_id1create_time1update_time1is_delete1for each col in CurrentObject.columnsnum num 1if col.Codecreate_user_id thencreate_user_id100end ifif col.Codecreate_time thencreate_time100end ifif col.Codeupdate_user_id thenupdate_user_id100end ifif col.Codeupdate_time thenupdate_time100end ifif col.Codeis_delete thenis_delete100end ifnextif create_user_id1 then CurrentObject.columns.CreateNewAt(num)for each col in CurrentObject.columns if col.DataType then col.Name创建人col.Codecreate_user_idcol.Comment创建人col.DataTypevarchar(64)col.Mandatory1end if nextnumnum1end ifif create_time1 then CurrentObject.columns.CreateNewAt(num)for each col in CurrentObject.columns if col.DataType then col.Name创建时间col.Codecreate_timecol.Comment创建时间col.DataTypedatetimecol.DefaultValueCURRENT_TIMESTAMPend if nextnumnum1end ifif update_user_id1 then CurrentObject.columns.CreateNewAt(num)for each col in CurrentObject.columns if col.DataType then col.Name修改人col.Codeupdate_user_idcol.Comment修改人col.DataTypevarchar(64) end if nextnumnum1end ifif update_time1 then CurrentObject.columns.CreateNewAt(num)for each col in CurrentObject.columns if col.DataType then col.Name修改时间col.Codeupdate_timecol.Comment修改时间col.DataTypedatetimecol.DefaultValueCURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMPend if nextnumnum1end ifif is_delete1 then CurrentObject.columns.CreateNewAt(num)for each col in CurrentObject.columns if col.DataType then col.Name删除标志col.Codeis_deletecol.Comment删除标志col.DataTypetinyintcol.DefaultValue0end if nextnumnum1end ifend if
End Sub2.2.统一删除字段 对于需要排除在外的表可添加在下面代码中 if instr(,Ex1,Ex2,,,tab.Code,)0 then Option Explicit
ValidationMode True
InteractiveMode im_BatchDim mdl 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 IfPrivate sub ProcessFolder(CurrentObject)Dim Tab
for each Tab in CurrentObject.tablesif instr(,Ex1,Ex2,,,tab.Code,)0 then if not tab.isShortcut thenDim col for each col in tab.columnsif instr(col.code,update_user_id)0 thencol.Deleteend ifif instr(col.code,update_time)0 thencol.Deleteend ifif instr(col.code,create_user_id)0 thencol.Deleteend ifif instr(col.code,create_time)0 thencol.Deleteend ifnextend ifend ifnext
MsgBox successend sub2.3.统一修改表名称
Option Explicit
ValidationMode True
InteractiveMode im_BatchDim mdl 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.
ElseProcessFolder mdl
End IfPrivate sub ProcessFolder(CurrentObject)Dim Tab Dim NameStr , CodeStrfor each Tab in CurrentObject.tables Tab.name Replace( Tab.name , ori_name , new_name)Tab.code Replace( Tab.code , s_ , student_)nextMsgBox success
end sub2.4. 统一修改字段属性 对于需要排除在外的表可添加在下面代码中 if instr(,Ex1,Ex2,,,tab.Code,)0 then dim model set model ActiveModel
If (model Is Nothing) ThenMsgBox There is no current ModelElseIf Not model.IsKindOf(PdPDM.cls_Model) ThenMsgBox The current model is not an Physical Data model.ElseProcessTables modelProcessSequences modelMsgBox success End Ifsub ProcessSequences(folder)dim sequencefor each sequence in folder.sequencessequence.name LCase(sequence.name)sequence.code LCase(sequence.code)nextend subsub ProcessTables(folder)dim tablefor each table in folder.tablesif instr(,Ex1,Ex2,,,table.Code,)0 then if not table.IsShortCut then ProcessTable tableend ifend ifnextdim subFolderfor each subFolder in folder.PackagesProcessTables subFoldernext
end subsub ProcessTable(table)dim colfor each col in table.Columnsif col.code s_name then col.code student_name col.DataType vachar(64)col.DefaultValue1col.Mandatory0end ifcol.code LCase(col.code)col.name LCase(col.name)next table.name UCase(table.name)table.code UCase(table.code)end sub对于其他需要修改的属性可在ProcessTable方法中自定义编辑代码
2.5.其他函数
在2.4.中将ProcessTables subFolder调用的方法替换为下述方法即可
表字段的部分替换 sub ReplaceCol(table)dim colfor each col in table.Columnsif instr(col.code,qty)0 then col.code Replace(col.code,qty,quantity)end ifif instr(col.code,amt)0 then col.code Replace(col.code,amt,amount)end ifnext end sub