PowerDesigner中表名和字段名大小写转换

 

面对不同的数据库大小写规范,一个个字段修改太麻烦了,如果使用了PowerDesigner设计,有比较简单的方法。进入PowerDesigner,打开一个PDM,在菜单栏找到:Tools – Excute Commands – Edit/Run Script,或者直接按Ctrl+Shift+X调出脚本执行窗口,输入下边的代码就可以了。使用的是VBScript,语义比较容易理解,可以根据自己的需求修改。

Option Explicit

ValidationMode = True

InteractiveMode = im_Batch

  

Dim mdl ' 当前模型

  

' 获取当前模型

Set mdl = ActiveModel

If (mdl Is Nothing) Then

   MsgBox"没有打开一个模型"

ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then

   MsgBox"当前模型不是一个PDM"

Else

'调用处理程序

   ProcessFolder mdl

End If

  

'调用的处理程序

Private sub ProcessFolder(folder)

   Dim Tab '要处理的表

   foreach Tab infolder.Tables

    'if not Tab.isShortcut then

        ' Tab.code = tab.name

        '表名处理,前边添加前缀,字母小写

        Tab.name="t_"+LCase(Tab.name)

         Dim col ' 要处理的列

         foreach col inTab.columns

            '列名称和code全部小写,大写诗UCase

            col.code= LCase(col.code)

            col.name= LCase(col.name)

         next

      'endif

   next

  

' 处理视图

'  Dim view 'running view

'   foreach view infolder.Views

   '  if not view.isShortcut then

       '  view.code = view.name

    '  endif

  ' next

  

   ' 递归进入 sub-packages

   Dim f ' sub  folder

   For Each f In folder.Packages

      ifnot f.IsShortcut then

         ProcessFolder f

      endif

   Next

end sub

你可能感兴趣的:(PowerDesigner中表名和字段名大小写转换)