PowerDesigner VB 脚本
shift+ctrl+x执行
批量添加字段(无则添加)
Option Explicit Dim mdl ' the current model Set mdl = ActiveModel Dim Tab 'running table Dim col_create_date, col_update_date,col_create_by,col_update_by,col_is_delete ' 定义属性变量 for each Tab in mdl.Tables Dim col Dim has_create_date,has_update_date,has_create_by,has_update_by has_create_date=0 has_update_date=0 has_create_by=0 has_update_by=0 For Each col In Tab.columns If (col.code = "create_date") Then has_create_date = 1 End If If (col.code = "update_date") Then has_update_date = 1 End If If (col.code = "create_by") Then has_create_by = 1 End If If (col.code = "update_by") Then has_update_by = 1 End If Next If (has_create_date=0) Then Set col_create_date = Tab.Columns.CreateNew col_create_date.name = "创建时间" col_create_date.code = "create_date" col_create_date.comment = "创建时间" col_create_date.DataType = "DateTime" End If If (has_update_date=0) Then set col_update_date = Tab.Columns.CreateNew col_update_date.name = "修改时间" col_update_date.code = "update_date" col_update_date.comment = "修改时间" col_update_date.DataType = "DateTime" End If If (has_create_by=0) Then set col_create_by = Tab.Columns.CreateNew col_create_by.name = "创建人" col_create_by.code = "create_by" col_create_by.comment = "创建人" col_create_by.DataType = "VARCHAR(32)" End If If (has_update_by=0) Then set col_update_by = Tab.Columns.CreateNew col_update_by.name = "更新人" col_update_by.code = "update_by" col_update_by.comment = "更新人" col_update_by.DataType = "VARCHAR(32)" End If next