博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PowerDesigner中pdm物理模型中 Name和Comment相互转换
阅读量:7058 次
发布时间:2019-06-28

本文共 3345 字,大约阅读时间需要 11 分钟。

  hot3.png

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

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

1、将Name中的内容复制至Comment中

Option   Explicit ValidationMode   =   True InteractiveMode   =   im_BatchDim   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

2、将Comment中的内容复制至Name中

Option   Explicit ValidationMode   =   True InteractiveMode   =   im_BatchDim   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   IfPrivate   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进行操作

转载于:https://my.oschina.net/ruoli/blog/1861545

你可能感兴趣的文章
中小企业网络方案商该关注哪些增值空间?
查看>>
苹果Safari浏览器遭遇全球故障 搜索即崩溃
查看>>
周鸿祎谈360回归初衷
查看>>
安防爆发年 谈谈车牌识别如何实现从原理到应用的转变?
查看>>
凯立德智慧物流地图服务平台让物流行业更省心
查看>>
安防产业布局跨境电商 有哪些方法?
查看>>
明晰监管范围保护信息安全
查看>>
超融合架构:主数据存储使命之外
查看>>
澳大利亚电信公布其可编程网络计划
查看>>
《Excel数据可视化:一样的数据不一样的图表》——3.2 用项目规则显示隐藏在计算机中的数据...
查看>>
诺基亚将在 MWC 上发布低成本 Android 手机
查看>>
《Outlook时间整理术》一不是电子邮件的问题,而是我们应如何处理它
查看>>
《Adobe Premiere Pro CS5经典教程》——第1课 Adobe Premiere Pro CS5概述 1.1 Adobe Premiere Pro CS5中的新功能...
查看>>
设计师是不是真正的用户
查看>>
《CCIE路由和交换认证考试指南(第5版) (第1卷)》——1.2节以太网第1层:线缆、速率和双工...
查看>>
补丁不起作用:Mac平台安全漏洞仍然存在
查看>>
《Spark核心技术与高级应用》——导读
查看>>
首席技术官 (CTO) 比普通程序员强在哪
查看>>
《交互式程序设计 第2版》一1.4 艺术与交互
查看>>
《脱颖而出——成功网店经营之道》一2.2 进货攻略
查看>>