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

  

转载于:https://www.cnblogs.com/china2k/p/9882543.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值