`

powerdesigner中name属性变为注释

 
阅读更多

在使用PowerDesigner对数据库进行概念模型和物理模型设计时,一般在NAME或Comment中写中文,在Code中写英文。Name用来显 示,Code在代码中使用,但Comment中的文字会保存到数据库Table或Column的Comment中,当Name已经存在的时候,再写一次 Comment很麻烦,可以使用以下代码来解决这个问题:
代码一:将Name中的字符COPY至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. '   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 

注意:如果不想把以前写的注释给覆盖掉 ,那么把上面的红色标记处  改成:   col.comment=   col.name    + col.comment  那么注释就是追加的了

 

 另外在使用REVERSE ENGINEER从数据库反向生成PDM的时候,PDM中的表的NAME和CODE事实上都是CODE,为了把NAME替换为数据库中Table或Column的中文Comment,可以使用以下脚本:

代码二:将Comment中的字符COPY至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. 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 

以上两段代码都是VB脚本,在PowerDesigner中使用方法为:
    PowerDesigner->Tools->Execute Commands->Edit/Run Scripts
将代码Copy进去执行就可以了,是对整个CDM或PDM进行操作

分享到:
评论

相关推荐

    powerdesigner,将name自动填充到注释(comment)。

    保存这个脚本为“name变成注释.vbs”,然后在“Execute Commands”的“Script File”(脚本文件)框中选择这个文件。点击“Run”(运行)按钮,脚本会开始执行,将所有符合条件的字段名称自动填充到对应的注释中。 ...

    powerdesigner逆向生成工具将注释字段添加到name字段上

    powerdesigner逆向工程导入mysql脚本生成PDM带全注释

    解决PowerDesigner中Name与Code同步的问题

    通过取消“Name to Code mirroring”复选框,我们可以让 Code 不与 Name 一起联动,从而解决 PowerDesigner 中 Name 与 Code 同步的问题。 PowerDesigner 中的 Name 与 Code -------------------------------- 在 ...

    powerdesigner画ER图显示注释

    一个小脚本,可以让powerdesigner显示的ER图添加注释,不过需要做一些设置

    PowerDesigner中显示name,code,comment的解决方法

    PowerDesigner是一款功能强大的数据模型设计工具,但是在某些版本中,视图不支持同时显示name、code、comment(列注释)。本文档将介绍如何在PowerDesigner中显示name、code、comment,解决了这个问题。 问题描述:...

    PowerDesigner中的name和comment互换

    在PowerDesigner这款数据建模和设计工具中,name和comment的互换是一个重要的操作...通过理解和实践PowerDesigner中的name和comment互换脚本,可以进一步加深对数据模型结构和属性的理解,提升处理数据模型的专业能力。

    PowerDesigner 中name和comment 互换脚本

    PowerDesigner中的name属性通常用于定义对象的唯一标识,比如表名、字段名等,而comment则用于添加对这些对象的描述性注释。在某些情况下,用户可能需要批量修改或交换这些属性,比如在整理模型文档时,为了保持一致...

    PowerDesigner导出的SQL带列注释,导入到MySQL中列注释不见了的处理方法

    PowerDesigner 导出的 SQL 带列注释,导入到 MySQL 中列注释不见了的处理方法 在使用 PowerDesigner 导出 SQL 文件时,如果包含列注释,可能会在导入到 MySQL 数据库中时丢失。这是因为 PowerDesigner 导出的 SQL ...

    解决PowerDesigner中Name与Code同步的问题.doc

    在使用PowerDesigner的过程中,有时会遇到一个常见的问题,即Name(名称)与Code(代码)同步的问题。这个问题指的是当用户修改了一个实体或字段的Name时,其对应的Code也会自动更新,这可能不符合开发者的预期,...

    powerDesigner 把name项添加到注释(comment)的脚本 name2comment.vbs

    powerDesigner 把name项添加到comment 使用方法使用方法 PowerDesigner->Tools->Execute Commands->Edit/Run Scripts 可以保存该脚本为:name2comment.vbs

    powerdesigner添加数据源、反向工程、表显示注释

    在 PowerDesigner 中,表的注释默认情况下不显示。要显示表的注释,需要按照以下步骤操作: 1. 打开工具菜单:点击“Tools”菜单,然后选择“Display Preferences”。 2. 选择表:选择要显示注释的表,然后点击...

    PowerDesigner连接MySQL互相导入以及显示中文注释

    ### PowerDesigner连接MySQL互相导入及显示中文注释详解 #### 一、安装ODBC驱动 在进行PowerDesigner与MySQL之间的连接之前,首先需要确保已经安装了ODBC (Open Database Connectivity) 驱动。ODBC驱动是实现不同...

    PowerDesigner逆向工程-Mysql,并解决没有注释的问题!

    本文将深入探讨如何使用PowerDesigner进行MySQL数据库的逆向工程,并解决逆向工程过程中可能出现的没有注释的问题。 首先,让我们了解什么是逆向工程。逆向工程,也称为数据库反向设计,是指从已有的数据库中提取其...

    PowerDesigner批量生成SQL脚本时将name生成数据库中字段的comment

    在本篇中,我们将探讨如何使用PowerDesigner批量生成SQL脚本来将name属性转换为数据库中字段的comment。 首先,我们需要了解PowerDesigner中的PDM(Physical Data Model),这是一个物理数据模型,它包含了数据库的...

    PowerDesigner 把name写到Comment中 和 把Comment写到name中 pd7以后版本可用

    标题中的“PowerDesigner 把name写到Comment中 和 把Comment写到name中 pd7以后版本可用”指的是一项在PowerDesigner中操作模型属性的方法。PowerDesigner是一款强大的数据建模工具,广泛应用于数据库设计和逆向工程...

    PowerDesigner生成带注释的pdm脚本

    当PowerDesigner连接好数据库,并生成模型后,在PowerDesigner用Ctrl+Shift+x快捷键打开,然后将脚本内容粘贴运行,就可以开始生成数据库中存在的注释了

    powerdesigner_comment转name_name转comment

    标题“powerdesigner_comment转name_name转comment”指的是使用PowerDesigner工具进行数据库设计时,将字段注释(comment)与字段名(name)之间进行互相转换的功能。在数据库设计过程中,注释对于理解和维护数据库...

    powerdesigner生成含注释的sql

    标题中的"powerdesigner生成含注释的sql"指的是使用PowerDesigner这款强大的数据库设计工具来创建包含注释的SQL脚本。PowerDesigner是一款流行的数据建模工具,它可以帮助IT专业人员进行概念数据模型(CDM)、物理...

    powerdesigner 显示注释程序

    在默认情况下,PowerDesigner并不直接显示模型中的对象注释,这对于理解和维护复杂的数据库模型可能会造成不便。"显示注释程序"正是为了解决这个问题而存在的,它是一个VBS(Visual Basic Script)脚本,能够帮助...

    使用PowerDesigner对NAME和COMMENT互相转换.docx

    这段脚本将COMMENT中的字符复制到NAME中,确保NAME反映数据库的实际注释。 由于给出的文件内容不完整,无法提供完整的代码二。不过,其基本思路是遍历所有表和列,检查COMMENT字段,并将其内容移动到NAME字段。一旦...

Global site tag (gtag.js) - Google Analytics