powerdesigner 编写pdm文件&导出sql

版权声明:本文为博主辛苦原创文章,未经博主允许不得转载。 https://blog.csdn.net/Nut___/article/details/84994778

目录

 

概要

一、设置编辑列

二、设置表显示内容

三、name&code取消同步

五、设置表字符编码 utf-8

六、name&comment 相互赋值

七、导出sql文件


概要

按照下面的步骤,最终可以形成下图的形式。

一、设置编辑列

二、设置表显示内容

1、打开 Tools-Display Preference

2、显示表的注释

3、显示列

注:上面显示没有注释,所以使用name充当注释的角色。可以在设置表时,填写name和code,然后使用下面的脚本将name复制到comment。

最终显示结果:

三、name&code取消同步

Tools→General Options→Dialog→Name to Code mirroring(取消勾选)→最后确定

四、设置默认值

注: text类型不能赋默认值

五、设置表字符编码 utf-8

在用PowerDesigner创建表的时候可以设置表的字符编码,进入到Physical Options标签,在左侧列表中有一个charset=utf8或GBK等之类的选项,选中这个即可。

如果没有看到这个字符编码选项,则需要自己手动进行设置

1、在PowerDesigner 16的安装目录Resource Files\DBMS下,找到mysql50.xdb这个文件(以mysql为例说明)

2、找到这一行:

checksum = %d : list = 0 | 1, default = 0

3、在其前一行或后一行加入,表示默认字符编码为UTF8

charset = %s : list = UTF8 | GBK | GB2312, default = UTF8

六、name&comment 相互赋值

1、进入

2、将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

3、将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   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

七、导出sql文件

按ctrl+G 打开对话框

猜你喜欢

转载自blog.csdn.net/Nut___/article/details/84994778