本文来自我的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. [SinGuLaRiTy] 复习模板-图论

    [SinGuLaRiTy-1041] Copyright (c) SinGuLaRiTy 2017. All Rights Reserved. 计算树的直径 //方法:任选一个点作为起点进行一次BFS ...

  2. 关于MacOS升级10.13系统eclipse菜单灰色无法使用解决方案

    最近,苹果发布了macOS High Sierra,版本为10.13,专门针对mac pro的用户来着,至于好处大家到苹果官网看便是,我就是一个升级新版本系统的受益者,同时也变成了一个受害者:打开ec ...

  3. 一篇文章帮你解决python的包管理

    写python代码的人都知道,一个项目写下下来,不可避免的都需要使用很多第三方包,通常我们都是通过pip install ,然而当我们需要上线的时候问题来了,如果中间你自己不记得自己安装了多少个包,这 ...

  4. K8S API 调用

    不好意,本人比较懒,OneNote 复制粘贴的时候就是自动变成图片了.请各位看官多多见谅. 遗留问题: 目前pod仅支持修改 * and(),so...

  5. python 操作python

    #!/usr/bin/env python#_*_ coding:utf-8 _*_ import MySQLdb # 打开门conn = MySQLdb.connect(host='192.168. ...

  6. 关于 tomcat 配置时遇到的问题与警告及解决办法

    首先,我们在日常配置 tomcat 时,总是会遇到这样的问题: 有时候我们会重新头来配置 tomcat,但是现在我们并不需要那么做,方法很简单,请继续往下看: 这个问题是告诉我们 tomcat 在 4 ...

  7. JDBC (一)

    1 JDBC 简介 sun公司为了简化.统一对数据库的操作,定义了一套java操作数据库的规范,称之为JDBC. 数据库厂商的驱动就是对JDBC的实现. 没有JDBC之前  vs 有JDBC之后 JD ...

  8. jenkins插件安装与升级[三]

    标签(linux): jenkins 笔者Q:972581034 交流群:605799367.有任何疑问可与笔者或加群交流 默认的插件 Folders Plugin OWASP Markup Form ...

  9. 十二条Linux运维面试必备经典笔试/面试题

    1.Linux设置环境变量 暂时的:export MYNAME="new name" echo $MYNAME new name 永久的:通过改变/etc/profile实现 EG ...

  10. the first simple html page generated by div and table tags

          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w ...