PowerDesigner16.5快速入门显示,注释comment配置方法,以及创建sql文件过程中需要注意的一些问题

   本章节讲解,使用PowerDesigner16.5数据库建模时快速上手遇到的一些问题及如何解决问题的过程:

如下图所示,创建模型:


如下图,选择物理模型的同时指定数据库管理系统:


如下图,选择Table新建表,点击之后在中间位置点击一次即可,选择如下图剪刀上面的图片开始进行操作:


如下图,本次只演示一下,因此使用两个字段信息来演示,需要使用注解就是直接在Name列来描述Code的字段的作用:



如下图,选择如下图进行视图里面的操作,接下里的操作如下图后面的图操作:


如下图,操作如下 Select Attributes视图,勾上CodeAttribute Name顺序如下即可:


如下图,满足了所需的要求:


如下图,在视图显示表的comment注释的操作:


如下图,选择合适的数据库系统:



如下图,表导出sql文件需要注意的一些问题:


导出SQL文件时,把Name列设置code列的注释,操作步骤如下:

步骤一:Database->Edit Current DBMS,如上图。

步骤二:如下图:

方法一:


以上是默认内容:

comment on column

[%QUALIFIER%]%TABLE%.%COLUMN% is
%.q:COMMENT%

改成:

comment on column [%QUALIFIER%]%TABLE%.%COLUMN% is
%.q:COLNNAME%

方法二:

操作:Database–>Edit Current DBMS,进入下图页面,

然后分别将

Script–>Objects–>Table–>TableComment

Script–>Objects–>Column–>ColumnComment

修改成

alter table [%QUALIFIER%]%TABLE% comment %.60qA:COMMENT%

alter table [%QUALIFIER%]%TABLE% modify column %COLUMN% %DATATYPE% comment %.60qA:COMMENT%


步骤三:解决当comment为空时,则不能生成注释的问题:

物理模型生产数据库时,Database->Generate Database..
在Format标签选项中,将Generate name in empty comment,勾选上,默认不勾选,同时设置编码Encoding防止乱码发生。


如下,有两个脚本的生成注释的作用:

comment的内容替换成name列的内容

  1. Option   Explicit     
  2. ValidationMode   =   True     
  3. InteractiveMode   =   im_Batch    
  4.     
  5. Dim   mdl   ’   the   current   model    
  6.     
  7. ‘   get   the   current   active   model     
  8. Set   mdl   =   ActiveModel     
  9. If   (mdl   Is   Nothing)   Then     
  10.       MsgBox   “There   is   no   current   Model ”     
  11. ElseIf   Not   mdl.IsKindOf(PdPDM.cls_Model)   Then     
  12.       MsgBox   “The   current   model   is   not   an   Physical   Data   model. ”     
  13. Else     
  14.       ProcessFolder   mdl     
  15. End   If    
  16.     
  17. ‘   This   routine   copy   name   into   comment   for   each   table,   each   column   and   each   view     
  18. ‘   of   the   current   folder     
  19. Private   sub   ProcessFolder(folder)     
  20.       Dim   Tab   ‘running     table     
  21.       for   each   Tab   in   folder.tables     
  22.             if   not   tab.isShortcut   then     
  23.                   tab.comment   =   tab.name     
  24.                   Dim   col   ’   running   column     
  25.                   for   each   col   in   tab.columns     
  26.                         col.comment=   col.name     
  27.                   next     
  28.             end   if     
  29.       next    
  30.     
  31.       Dim   view   ‘running   view     
  32.       for   each   view   in   folder.Views     
  33.             if   not   view.isShortcut   then     
  34.                   view.comment   =   view.name     
  35.             end   if     
  36.       next    
  37.     
  38.       ’   go   into   the   sub-packages     
  39.       Dim   f   ’   running   folder     
  40.       For   Each   f   In   folder.Packages     
  41.             if   not   f.IsShortcut   then     
  42.                   ProcessFolder   f     
  43.             end   if     
  44.       Next     
  45. end   sub  
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

把name列的内容替换成comment列的内容

  1. Option   Explicit     
  2. ValidationMode   =   True     
  3. InteractiveMode   =   im_Batch    
  4.     
  5. Dim   mdl   ’   the   current   model    
  6.     
  7. ‘   get   the   current   active   model     
  8. Set   mdl   =   ActiveModel     
  9. If   (mdl   Is   Nothing)   Then     
  10.       MsgBox   “There   is   no   current   Model ”     
  11. ElseIf   Not   mdl.IsKindOf(PdPDM.cls_Model)   Then     
  12.       MsgBox   “The   current   model   is   not   an   Physical   Data   model. ”     
  13. Else     
  14.       ProcessFolder   mdl     
  15. End   If    
  16.     
  17. Private   sub   ProcessFolder(folder)     
  18. On Error Resume Next    
  19.       Dim   Tab   ‘running     table     
  20.       for   each   Tab   in   folder.tables     
  21.             if   not   tab.isShortcut   then     
  22.                   tab.name   =   tab.comment    
  23.                   Dim   col   ’   running   column     
  24.                   for   each   col   in   tab.columns     
  25.                   if col.comment=”“ then    
  26.                   else    
  27.                         col.name=   col.comment     
  28.                   end if    
  29.                   next     
  30.             end   if     
  31.       next    
  32.     
  33.       Dim   view   ‘running   view     
  34.       for   each   view   in   folder.Views     
  35.             if   not   view.isShortcut   then     
  36.                   view.name   =   view.comment     
  37.             end   if     
  38.       next    
  39.     
  40.       ’   go   into   the   sub-packages     
  41.       Dim   f   ’   running   folder     
  42.       For   Each   f   In   folder.Packages     
  43.             if   not   f.IsShortcut   then     
  44.                   ProcessFolder   f     
  45.             end   if     
  46.       Next     
  47. end   sub  
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

如下图,执行命令:



powerdesigner中给一主键设为自增型auto_increment,光标选中该列右键选择properties或者按快捷键 alt+enter,勾选Domain后面的Identity即可,然后查看preview。


   本章节讲解,使用PowerDesigner16.5数据库建模时快速上手遇到的一些问题及如何解决问题的过程:

如下图所示,创建模型:


如下图,选择物理模型的同时指定数据库管理系统:


如下图,选择Table新建表,点击之后在中间位置点击一次即可,选择如下图剪刀上面的图片开始进行操作:


如下图,本次只演示一下,因此使用两个字段信息来演示,需要使用注解就是直接在Name列来描述Code的字段的作用:



如下图,选择如下图进行视图里面的操作,接下里的操作如下图后面的图操作:


如下图,操作如下 Select Attributes视图,勾上CodeAttribute Name顺序如下即可:


如下图,满足了所需的要求:


如下图,在视图显示表的comment注释的操作:


如下图,选择合适的数据库系统:



如下图,表导出sql文件需要注意的一些问题:


导出SQL文件时,把Name列设置code列的注释,操作步骤如下:

步骤一:Database->Edit Current DBMS,如上图。

步骤二:如下图:

方法一:


以上是默认内容:

comment on column

[%QUALIFIER%]%TABLE%.%COLUMN% is
%.q:COMMENT%

改成:

comment on column [%QUALIFIER%]%TABLE%.%COLUMN% is
%.q:COLNNAME%

方法二:

操作:Database–>Edit Current DBMS,进入下图页面,

然后分别将

Script–>Objects–>Table–>TableComment

Script–>Objects–>Column–>ColumnComment

修改成

alter table [%QUALIFIER%]%TABLE% comment %.60qA:COMMENT%

alter table [%QUALIFIER%]%TABLE% modify column %COLUMN% %DATATYPE% comment %.60qA:COMMENT%


步骤三:解决当comment为空时,则不能生成注释的问题:

物理模型生产数据库时,Database->Generate Database..
在Format标签选项中,将Generate name in empty comment,勾选上,默认不勾选,同时设置编码Encoding防止乱码发生。


如下,有两个脚本的生成注释的作用:

comment的内容替换成name列的内容

  1. Option   Explicit     
  2. ValidationMode   =   True     
  3. InteractiveMode   =   im_Batch    
  4.     
  5. Dim   mdl   ’   the   current   model    
  6.     
  7. ‘   get   the   current   active   model     
  8. Set   mdl   =   ActiveModel     
  9. If   (mdl   Is   Nothing)   Then     
  10.       MsgBox   “There   is   no   current   Model ”     
  11. ElseIf   Not   mdl.IsKindOf(PdPDM.cls_Model)   Then     
  12.       MsgBox   “The   current   model   is   not   an   Physical   Data   model. ”     
  13. Else     
  14.       ProcessFolder   mdl     
  15. End   If    
  16.     
  17. ‘   This   routine   copy   name   into   comment   for   each   table,   each   column   and   each   view     
  18. ‘   of   the   current   folder     
  19. Private   sub   ProcessFolder(folder)     
  20.       Dim   Tab   ‘running     table     
  21.       for   each   Tab   in   folder.tables     
  22.             if   not   tab.isShortcut   then     
  23.                   tab.comment   =   tab.name     
  24.                   Dim   col   ’   running   column     
  25.                   for   each   col   in   tab.columns     
  26.                         col.comment=   col.name     
  27.                   next     
  28.             end   if     
  29.       next    
  30.     
  31.       Dim   view   ‘running   view     
  32.       for   each   view   in   folder.Views     
  33.             if   not   view.isShortcut   then     
  34.                   view.comment   =   view.name     
  35.             end   if     
  36.       next    
  37.     
  38.       ’   go   into   the   sub-packages     
  39.       Dim   f   ’   running   folder     
  40.       For   Each   f   In   folder.Packages     
  41.             if   not   f.IsShortcut   then     
  42.                   ProcessFolder   f     
  43.             end   if     
  44.       Next     
  45. end   sub  
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

把name列的内容替换成comment列的内容

  1. Option   Explicit     
  2. ValidationMode   =   True     
  3. InteractiveMode   =   im_Batch    
  4.     
  5. Dim   mdl   ’   the   current   model    
  6.     
  7. ‘   get   the   current   active   model     
  8. Set   mdl   =   ActiveModel     
  9. If   (mdl   Is   Nothing)   Then     
  10.       MsgBox   “There   is   no   current   Model ”     
  11. ElseIf   Not   mdl.IsKindOf(PdPDM.cls_Model)   Then     
  12.       MsgBox   “The   current   model   is   not   an   Physical   Data   model. ”     
  13. Else     
  14.       ProcessFolder   mdl     
  15. End   If    
  16.     
  17. Private   sub   ProcessFolder(folder)     
  18. On Error Resume Next    
  19.       Dim   Tab   ‘running     table     
  20.       for   each   Tab   in   folder.tables     
  21.             if   not   tab.isShortcut   then     
  22.                   tab.name   =   tab.comment    
  23.                   Dim   col   ’   running   column     
  24.                   for   each   col   in   tab.columns     
  25.                   if col.comment=”“ then    
  26.                   else    
  27.                         col.name=   col.comment     
  28.                   end if    
  29.                   next     
  30.             end   if     
  31.       next    
  32.     
  33.       Dim   view   ‘running   view     
  34.       for   each   view   in   folder.Views     
  35.             if   not   view.isShortcut   then     
  36.                   view.name   =   view.comment     
  37.             end   if     
  38.       next    
  39.     
  40.       ’   go   into   the   sub-packages     
  41.       Dim   f   ’   running   folder     
  42.       For   Each   f   In   folder.Packages     
  43.             if   not   f.IsShortcut   then     
  44.                   ProcessFolder   f     
  45.             end   if     
  46.       Next     
  47. end   sub  
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

如下图,执行命令:



powerdesigner中给一主键设为自增型auto_increment,光标选中该列右键选择properties或者按快捷键 alt+enter,勾选Domain后面的Identity即可,然后查看preview。


猜你喜欢

转载自blog.csdn.net/qq_34495557/article/details/79348300
今日推荐