******************************************************************************
'* File: name2comment.vbs
'* Purpose: Database generation cannot use object names anymore
' in version 7 and above.
' It always uses the object codes.
'
' In case the object codes are not aligned with your
' object names in your model, this script will copy
' the object Name onto the object Comment for
' the Tables and Columns.
'
'* Title:
'* Version: 1.0
'* author: jwdstef Inc.
'******************************************************************************
Option Explicit
ValidationMode = True
InteractiveMode = im_Batch
Dim mdl ' the current model
' get the current active model
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 If
' This routine copy name into comment for each table, each column and each view
' of the current folder
Private sub ProcessFolder(folder)
Dim Tab 'running table
for each Tab in folder.tables
if not tab.isShortcut then
tab.comment = tab.name
Dim col ' running column
for each col in tab.columns
col.comment= col.name
next
end if
next
Dim view 'running view
for each view in folder.Views
if not view.isShortcut then
view.comment = view.name
end if
next
' go into the sub-packages
Dim f ' running folder
For Each f In folder.Packages
if not f.IsShortcut then
ProcessFolder f
end if
Next
end sub
'下面是comment2name
Option Explicit
ValidationMode = True
InteractiveMode = im_Batch
Dim mdl ' the current model
' get the current active model
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 If
Private sub ProcessFolder(folder)
On Error Resume Next
Dim Tab 'running table
for each Tab in folder.tables
if not tab.isShortcut then
tab.name = tab.comment
Dim col ' running column
for each col in tab.columns
if col.comment="" then
else
col.name= col.comment
end if
next
end if
next
Dim view 'running view
for each view in folder.Views
if not view.isShortcut then
view.name = view.comment
end if
next
' go into the sub-packages
Dim f ' running folder
For Each f In folder.Packages
if not f.IsShortcut then
ProcessFolder f
end if
Next
end sub
Option Explicit
Dim mdl ' the current model
Set mdl = ActiveModel
Dim Tab 'running table
Dim col_ModTime, col_ModPerson ,col_CreatPersion,col_CreatTime
' 定义属性变量
for each Tab in mdl.Tables
if not tab.isShortcut then
Set col_ModTime = Tab.Columns.CreateNew
set col_ModPerson = Tab.Columns.CreateNew
set col_CreatPersion=Tab.Columns.CreateNew
set col_CreatTime=Tab.Columns.CreateNew
col_CreatPersion.name = "创建人"
col_CreatPersion.code = "CREATOR"
col_CreatPersion.DataType = "VARCHAR2(20)"
col_CreatTime.name = "创建日期"
col_CreatTime.code = "CREATE_DATE"
col_CreatTime.DataType = "DATE"
col_ModPerson.name = "修改人"
col_ModPerson.code = "MODIFIER"
col_ModPerson.DataType = "VARCHAR2(20)"
col_ModTime.name = "修改日期"
col_ModTime.code = "MODIFY_DATE"
col_ModTime.DataType = "DATE"
end if
next
-----------------
如果直接导出脚本的话,所有的表和字段都会被加上双引号,不能直接导入数据库。
所以我们得让导出的SQL字段去掉双引号,具体操作方法如下:
选择Database->Edit current database->Script->Sql->Format,有一项CaseSensitivityUsingQuote,它的comment为“Determines if the case sensitivity for identifiers is managed using double quotes”,表示是否适用双引号来规定标识符的大小写,可以看到右边的values默认值为“YES”,改为“No”即可!
或者在打开pdm的情况下,进入Tools-Model Options-Naming Convention,把Name和Code的标签的Charcter case选项设置成Uppercase就可以!
Name和Code 的右侧都有一个按钮“=”,如果需要不同步的话,把这个按钮弹起来就可以了。
Tools->General Options->Dialog->Name to Code Mirroring (去掉)