PowerDesigner数据库建模将所有表同一个字段统一设置字段属性

PowerDesigner数据库建模将所有表同一个字段统一设置字段属性(统一修改某个字段属性)
在大型系统建模时,同一字段存在多个表中,有时需将这个字段的属性设为一致,一个一个表去设麻烦也有可能漏掉,我们可以写一段VBS代码统一修改,如下是为“IsDelete”字段统一1.字段类型为DATE 2.必填 3.默认值0

Tools->Execute Commands->Edit/Run Script 弹出窗 将如下代码贴入 点击 Run 即可

Option Explicit
ValidationMode = True
InteractiveMode = im_Batch
 
'ceaate by runnerrunning 
 
' get the current active model
Dim mdl ' the current model
dim TestDataObj 
Set mdl = ActiveModel
If (mdl Is Nothing) Then
   MsgBox "There is no Active Model"
Else
   ListObjects(mdl)
End If
 
 
'-----------------------------------------------------------------------------
Private Sub ListObjects(fldr) '列出所有的对象
   output "Scanning " & fldr.code
   Dim obj ' running object
   
   For Each obj In fldr.children
      ' Calling sub procedure to print out information on the object
      
      TableSetComment obj
   Next
 
   		' go into the sub-packages
   Dim f ' running folder
   For Each f In fldr.Packages '递归调用列出所有的对象
      'calling sub procedure to scan children package
      ListObjects f
   Next
End Sub
 
 
Private Sub TableSetComment(CurrentObject)
   
   
   if not CurrentObject.Iskindof(cls_Table) then exit sub
   'output "Found "+CurrentObject.ClassName+" """+CurrentObject.Name+""", Created by "+CurrentObject.Creator+" On "+Cstr(CurrentObject.CreationDate)   
   'output "Found "+CurrentObject.ClassName+" ; "+CurrentObject.Name
      
      if not CurrentObject.isShortcut then
         'CurrentObject.Comment = CurrentObject.name &vbCrLf& CurrentObject.Comment
         Dim col  ' running column
         Dim num
         
         for each col in CurrentObject.columns
            if col.Code="IsDelete"  then
               output CurrentObject.Name
                  col.DataType="DATE"
                  col.Mandatory=1
                  col.DefaultValueDisplayed=0
            end if
            
         next
         
         
      end if      
End Sub
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值