转载:https://www.cnblogs.com/cxd4321/archive/2009/03/07/1405475.html

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

  • 代码一:将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

--------------------------------------------

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

  • 代码二:将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

-----------------------------------------------------------------------

以上两段代码都是VB脚本,在PowerDesigner中使用方法为:

PowerDesigner->Tools->Execute Commands->Edit/Run Scripts

将代码Copy进去执行就可以了,是对整个CDM或PDM进行操作

PowerDesigner 把Comment/name 互转的更多相关文章

  1. PowerDesigner执行脚本 name/comment/stereotype互转

    执行方法:工具栏->Tools -> Execute Commands -> Edit/Run Script (Ctrl+Shift+X) 如下图所示: 1.Name转到Commen ...

  2. PowerDesigner 把Comment复制到name中和把name复制到Comment

    在使用PowerDesigner对数据库进行概念模型和物理模型设计时,一般在NAME或Comment中写中文,在Code中写英文.Name用来显 示,Code在代码中使用,但Comment中的文字会保 ...

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

    在使用PowerDesigner对数据库进行概念模型和物理模型设计时,一般在NAME或Comment中写中文,在Code中写英文.Name用来显 示,Code在代码中使用,但Comment中的文字会保 ...

  4. [转]PowerDesigner 把Comment写到name中 和把name写到Comment中 pd7以后版本可用

    http://www.cnblogs.com/cxd4321/archive/2009/03/07/1405475.html 在使用PowerDesigner对数据库进行概念模型和物理模型设计时,一般 ...

  5. PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码

    在用PowerDesigner时.常常在NAME或Comment中写中文在Code中写英文.Name只会显示给我们看,Code会使用在代码中.但Comment中的文字会保存到数据库TABLE的Desc ...

  6. PowerDesigner 把Comment写到name中 和把name写到Comment中

    在使用PowerDesigner对数据库进行概念模型和物理模型设计时,一般在NAME或Comment中写中文,在Code中写英文.Name用来显 示,Code在代码中使用,但Comment中的文字会保 ...

  7. 【PowerDesigner】【8】把Comment复制到name中和把name复制到Comment

    原因:这两个字段的值很多时候其实是一样的,重写很麻烦 步骤:打开菜单Tools>Execute Commands>Edit/Run Script.. 或者用快捷键 Ctrl+Shift+X ...

  8. 【PowerDesigner】【7】Table视图显示Comment

    原理:把显示name的列的值,替换成注释的值. 步骤:打开菜单Tools>Execute Commands>Edit/Run Script.. 或者用快捷键 Ctrl+Shift+X.将下 ...

  9. PowerDesigner逆向操作(从mysql5.0生成数据库的物理模型),把Comment写到name中,pdm文件导出为word

    PowerDesigner逆向操作(从mysql5.0生成数据库的物理模型) 环境:powderdesigner12.5:mysql5.0步骤:1. 为指定的数据库配置mysql的ODBC数据源先下载 ...

随机推荐

  1. SQL备份一张表的数据

    使用如下语句 SELECT  *  into   table_bak   FROM   table 可把表table中的数据备份到  table_bak   ,而且无需重新建table_bak .会自 ...

  2. 关于python单方法的类

    1.大部分情况下,你拥有一个单方法类的原因是需要存储某些额外的状态来给方法使用. 此种情况下可以使用闭包代替,参考 javascript的闭包计数器实现,python实现各种方法来实现计数器 关于这个 ...

  3. VSCode------搭建.net core 2.0,并配置到IIS服务器

    前奏 安装VSCode最新版: https://code.visualstudio.com/ 安装window server hosting,发布和部署到IIS使用: https://www.micr ...

  4. Java md5加密 控制台传入与web传入参数 结果不匹配 || 相同字符串加密结果不同,如何保证JAVA MD5加密结果在不同的环境下都相同

    开发中遇到md5加密不一致问题,排除了上下文编码,加密内容问题. 爬了各类资料,最终找到了原因. /** 对字符串进行MD5加密 */ private static String encodeByMD ...

  5. javascript全屏操作

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. iOS开发之-- 字符串的操作,去掉某一个字符或者替换成其他字符

    一个简单的操作,记录下: NSString *strUrl = [urlString stringByReplacingOccurrencesOfString:@" " withS ...

  7. Linux应急响应(三):挖矿病毒

    0x00 前言 ​ 随着虚拟货币的疯狂炒作,利用挖矿脚本来实现流量变现,使得挖矿病毒成为不法分子利用最为频繁的攻击方式.新的挖矿攻击展现出了类似蠕虫的行为,并结合了高级攻击技术,以增加对目标服务器感染 ...

  8. unity3d抛物线的脚本

    using UnityEngine; using System.Collections; public class ProjectileTest : MonoBehaviour { public Ga ...

  9. linux下使用ftp传递文件的shell脚本

    使用ftp传递文件,传递过程中防止对方取文件,后缀名为writing,传完后再改回来. #!/bin/bash dstpath=cnet ftpip="127.0.0.1" log ...

  10. 简单的Excel导入(上传、解析、持久化)

    /** * excel导入 * @param req * @param resp * @return */ public void excelImport(){ //先将要上传的Excel文件上传到项 ...