PowerDesigner->Tools->Execute Commands->Edit/Run Scripts
将代码Copy进去执行就可以了

将Comment中的字符COPY至Name中

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 a 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
      ' 修改表名:code + 空格 + comment
      ' 如果comment为空,则只使用code
      If Tab.comment <> "" Then
        Tab.name = Tab.code & " " & Tab.comment
      Else
        Tab.name = Tab.code
      End If
      
      Dim col   ' running column
      For Each col In Tab.columns
        ' 修改列名:code + 空格 + comment
        If col.comment <> "" Then
          col.name = col.comment
        Else
          col.name = col.code
        End If
      Next
    End If
  Next

  Dim view   ' running view
  For Each view In folder.Views
    If Not view.isShortcut Then
      ' 修改视图名:code + 空格 + comment
      If view.comment <> "" Then
        view.name = view.code & " " & view.comment
      Else
        view.name = view.code
      End If
    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

将Name中的字符COPY至Comment中

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

将每个表的Code附加到Name前面,格式为:原Code + 空格 + 原Name

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
      ' 将Code附加到Name前
      tab.name = tab.code & " " & tab.name
    End If
  Next
  
  ' 递归处理子包
  Dim f ' running folder
  For Each f In folder.Packages
    If Not f.IsShortcut Then
      ProcessFolder f
    End If
  Next
End Sub

只导出数据,带insert和字段

sudo -u postgres pg_dump -U postgres -d $1 --column-inserts --data-only -t 表名1  -t 表名2   -f $2.sql

导入

#!/bin/bash
sudo -u postgres psql -U postgres -d $1 < $2