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

摘要:
在使用PowerDesigner对数据库进行概念模型和物理模型设计时,一般在NAME或Comment中写中文,在Code中写英文。

在使用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   ExplicitValidationMode   =   TrueInteractiveMode   =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. "   
ElseProcessFolder   mdl   
End   If  
  
'This   routine   copy   name   into   comment   for   each   table,   each   column   and   each   view   'of   the   current   folder   
Private   subProcessFolder(folder)   
      Dim   Tab   'running     table   
      for   each   Tab   infolder.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   infolder.Views   
            if   not   view.isShortcut   thenview.comment   =view.name   
            end   if   
      next  
  
      'go   into   the   sub-packages   
      Dim   f   'running   folder   
      For   Each   f   Infolder.Packages   
            if   not   f.IsShortcut   thenProcessFolder   f   
            end   if   
      Next   
end   sub  

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

'代码二:将Comment中的字符COPY至Name中   
  
Option   ExplicitValidationMode   =   TrueInteractiveMode   =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. "   
ElseProcessFolder   mdl   
End   If  
  
Private   subProcessFolder(folder)   
On Error Resume Next  
      Dim   Tab   'running     table   
      for   each   Tab   infolder.tables   
            if   not   tab.isShortcut   then   
                  tab.name   =   tab.comment  
                  Dim   col   'running   column   
                  for   each   col   in   tab.columns   
                  if col.comment="" then  
                  elsecol.name=col.comment   
                  end if  
                  next   
            end   if   
      next  
  
      Dim   view   'running   view   
      for   each   view   infolder.Views   
            if   not   view.isShortcut   thenview.name   =view.comment   
            end   if   
      next  
  
      'go   into   the   sub-packages   
      Dim   f   'running   folder   
      For   Each   f   Infolder.Packages   
            if   not   f.IsShortcut   thenProcessFolder   f   
            end   if   
      Next   
end   sub  

免责声明:文章转载自《PowerDesigner 把Comment复制到name中和把name复制到Comment》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇ThinkPHP数组在JS里使用IIS7 使用server farms 进行负载均衡下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

UiPath Level 1-Lesson 3. Data Manipulation

学习大纲 如何拆分字符串 如何改变部分字符串的格式 如何在表格中根据条件选中特定的行 1. 标量型变量,集合,表格 活动的属性都有预定义的数据类型。鼠标悬停在属性面板的某个属性上,就会出现相应的提示。 使用右键菜单或Ctrl+K在属性栏创建的变量,会直接设置为属性预定义的类型。 标量型变量 (Scalar Variables):一个单独的固定类...

PowerDesigner常用快捷键

PowerDesigner常用快捷键 博客分类:PowerDesigner 浏览器活动UPF#J# 一般快捷键F4 打开检查模型窗口,检查模型F5 如果图窗口内的图改变过大小,恢复为原有大小即正常大小F6 放大图窗口内的图F7 缩小图窗口内的图F8 在图窗口内中查看全部图内容F9 预览图窗口F10 在图窗口中以一幅视图的高度显示图Shif...

【PowerDesigner】快速上手

破解下载地址: https://www.onlinedown.net/soft/577763.htm 安装点试用,完成安装后把破解的dll库文件替换即可 学习参考自: https://www.bilibili.com/video/BV17t411T7ju 运行程序,关闭工程选择弹窗 点左上角新建模型: 数据库模型构建选择的是物理数据模型 模型名称自己定义...

bxSlider使用

占个坑,有空仔细研究下。 官网:http://bxslider.com/ 优点: 1.完全响应-将适应任何设备2.水平,垂直和褪色模式3.它可以包括图片,视频,或HTML内容4.先进的触摸/刷卡支持内置5.使用css滑动动画(本地硬件加速!)6.全回调函数和公共方法7.小文件大小,完全主题,简单实现8.浏览器:Firefox,Chrome,Safari支持...

【12c】Oracle Restart中的SRVCTL命令详解

SRVCTL,服务控制实用工具(Service Control Utility),可用于对Oracle Restart和Oracle RAC的配置和管理,本篇主要介绍SRVCTL命令在Oracle Restart中的应用,其中,详细介绍config、status命令,并列出其它命令的用法。 1 srvctl命令语法 Usage: srvctl <co...

集成算法 ensemble method

introduction When you want to purchase a new car, will you walk up to the first car shop and purchase one based on the advice of the dealer? It’s highly unlikely. You would likely...