本文来自我的github pages博客http://galengao.github.io/ 即www.gaohuirong.cn

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

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

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

 

 

使用PowerDesigner对NAME和COMMENT互相转换的更多相关文章

  1. PowerDesigner中NAME和COMMENT的互相转换,需要执行语句

    原文: http://www.cnblogs.com/xnxylf/p/3288718.html 由于PDM 的表中 Name 会默认=Code 所以很不方便, 所以需要将 StereoType 显示 ...

  2. PowerDesigner中NAME和COMMENT的互相转换

    原文: http://www.cnblogs.com/yelaiju/archive/2013/04/26/3044828.html 由于PDM 的表中 Name 会默认=Code 所以很不方便, 所 ...

  3. PowerDesigner设计Name和Comment 替换

    这两天在用powerdesigner设计数据库.一直以为name就是注释名字来着.后来生成sql语句 怎么就没有注释信息那. 后来看了半天才知道自己范2了. 通过各种信息查找.大多都是改databas ...

  4. PowerDesigner 同步Name到Comment 及 同步 Comment 到Name

    PowerDesigner中使用方法为:     PowerDesigner->Tools->Execute Commands->Edit/Run Scripts 代码一:将Name ...

  5. 转载 - PowerDesigner(CDM—PDM—SQL脚本的转换流程)

    出处: http://jbeduhai.iteye.com/blog/338579 由于图片复制上去不显示,如想看内容及图片详情,请下载附件 PowerDesigner数据模型(CDM—PDM—SQL ...

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

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

  7. [转]PowerDesigner表结构和字段大小写转换

    原文地址:https://blog.csdn.net/u010216641/article/details/48712503 ##PowerDesigner去除双引号## 平时经常用PowerDesi ...

  8. 【转】PowerDesigner表结构和字段大小写转换

    [转自]http://blog.csdn.net/xysh1991/article/details/8016192 使用方法:进入PowerDesigner,打开一个PDM,在菜单栏找到:Tools ...

  9. powerDesigner的name和comment转化

    name2comment.vbs '****************************************************************************** '* ...

随机推荐

  1. 【编程技巧】Ext.MessageBox 大集合 不同的dialog图解加写法

    1.alert对话框 效果图: function a1(){ Ext.MessageBox.alert('title','text');  } 2.confirm案例,确定不确定2个按钮对话框 效果图 ...

  2. Excel的列编号 例如:A对应1,Z对应26,AA对应27,AZ对应52的JavaScript怎么写?

    今天碰到的题目,当时不会.回来想了一会,调试了一下,然后想上网对答案,发现竟然没有!!! function str(num){ if(num<=0){ alert("excel表格貌似 ...

  3. redis集群主从集群搭建、sentinel(哨兵集群)配置以及Jedis 哨兵模式简要配置

    前端时间项目上为了提高平台性能,为应用添加了redis缓存,为了提高服务的可靠性,redis部署了高可用的主从缓存,主从切换使用的redis自带的sentinel集群.现在权作记录.

  4. junit4X系列--Rule

    原文出处:http://www.blogjava.net/DLevin/archive/2012/05/12/377955.html.感谢作者的无私分享. 初次用文字的方式记录读源码的过程,不知道怎么 ...

  5. Linux 下 编译Xerces-c++

    按照 doc/html 文件夹中的详细指导编译 Xerces-C++ 共享库. 下面的命令展示了如何用压缩的源文件编译 Xerces-C++ 库. 这里假定在像 /home/ 这样的目录中有 xerc ...

  6. 长整形 Unix系统毫秒时间 (long类型) 转换为时间格式

    /** * 把毫秒转化成日期 * * @param dateFormat(日期格式,例如:MM/ dd/yyyy HH:mm:ss) * @param millSec(毫秒数) * @return * ...

  7. 【转】Linux 服务器安全配置

    第一部分:RedHat Linux篇1.概述 Linux服务器版本:RedHat Linux AS 2.1 对于开放式的操作系统---Linux,系统的安全设定包括系统服务最小化.限制远程存取.隐藏重 ...

  8. Java NIO 之 Selector

    Selector是SelectableChannel的多路选择器,配合SelectableChannel实现非阻塞IO. 详见代码 /** * Selector 是 SelectableChannel ...

  9. JSP自定义标签就是如此简单

    tags: JSP 为什么要用到简单标签? 上一篇博客中我已经讲解了传统标签,想要开发自定义标签,大多数情况下都要重写doStartTag(),doAfterBody()和doEndTag()方法,并 ...

  10. Centos系统下硬盘扩容

    装好CentOS后,发现空间太小,怎样才能增加硬盘容量?那就是再建一个硬盘: 打开虚拟经济的设置添加硬盘 查看现有的磁盘空间 fdisk -l [root@localhost ~]# fdisk -l ...