PowerDesign?是不是感觉很古老,用惯了而已。
以下代码参考网络整理而成,经本人优化并亲测通过。
==>name转code name格式: 中文#code
.set_value(_First, true, new)
.foreach_part(%Name%, "'#'")
.if (%_First%)
.delete(%CurrentPart%)
.set_value(_First, false, update)
.else
%CurrentPart%
.endif
.foreach_part(%Name%, "'#'")
.if (%_First%)
.delete(%CurrentPart%)
.set_value(_First, false, update)
.else
%CurrentPart%
.endif
.next
在PowerDesigner中使用方法为: PowerDesigner->Tools->Model Options->NamingConvention->name 【Enable name/code Conventions】->name to code
==>name转comment name格式: 中文#code
将table name的#号之前的文字变为table的comment,将column name的#号之前的文字变为column的comment.
原来的代码是针对一个folder(CDM或PDM)下所有表(还有其他view等)进行操作,改为可以只针对特定表进行操作,如果tabname有值,则就匹配tabname值,否则如果tabname为空,则对所有表进行操作。
在PowerDesigner中使用方法为: PowerDesigner->Tools->Execute Commands->Edit/Run Scripts
-----------------------------------------------------------------------------
Option Explicit
ValidationMode = True
InteractiveMode = im_Batch
Dim tabname
Dim mdl ' the current model
'如果tabname留空,则对所有表进行操作
tabname = "应答推荐"
' 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
dim cando
cando = 1
if tabname<>"" and Instr(tab.name, tabname) = 0 then
cando = 0
end if
'msgBox tab.name
'msgBox cando
if not tab.isShortcut and cando=1 then
InteractiveMode = im_Batch
Dim tabname
Dim mdl ' the current model
'如果tabname留空,则对所有表进行操作
tabname = "应答推荐"
' 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
dim cando
cando = 1
if tabname<>"" and Instr(tab.name, tabname) = 0 then
cando = 0
end if
'msgBox tab.name
'msgBox cando
if not tab.isShortcut and cando=1 then
msgBox "即将对如下表操作:"&tab.name
tab.comment = split(tab.name ,"#")(0)
Dim col ' running column
for each col in tab.columns
col.comment= split(col.name,"#")(0)
msgBox col.comment
next
end if
next
Dim view 'running view
for each view in folder.Views
if not view.isShortcut then
view.comment = split(view.name,"#")(0)
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
for each col in tab.columns
col.comment= split(col.name,"#")(0)
msgBox col.comment
next
end if
next
Dim view 'running view
for each view in folder.Views
if not view.isShortcut then
view.comment = split(view.name,"#")(0)
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,code,comment(列注释)同时显示,本文档完美解决了这个问题。快乐源于分享,需要的拿走
解决PowerDesigner中Name与Code同步的问题
解决PowerDesigner中Name与Code同步的问题
PowerDesigner->Tools->Execute Commands->Edit/Run Scripts 将comment覆盖name。 将name自动填充到注释(comment)。
NULL 博文链接:https://yanfei133.iteye.com/blog/1483094
PowerDesigner 中name和comment 互换脚本,可以使用。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
powerDesigner 把name项添加到comment 使用方法使用方法 PowerDesigner->Tools->Execute Commands->Edit/Run Scripts 可以保存该脚本为:name2comment.vbs
powerdesigner的大小写转换脚本,直接在powerdesigner里面找到执行脚本的地方,粘贴进去执行一下就可以了。 powerdesigner的大小写转换脚本 powerdesigner的大小写转换脚本
powerdesigner中name和code相关联对程序设计造成不便,可以按照文档进行设置;对于powerdesigner导出的sql代码有引号的解决方案。
PowerDesigner中使name列的值等于comment列的值的脚本,亲测可用
通常数据表字段使用英文,备注comment完成字段的说明。使用该脚本能够在PowerDesigner批量生成SQL脚本时将name生成数据库中字段的comment
可以很好的实现comment和name之间的相互转换,针对mysql数据库表的设计很方便
将powerdesigner中物理模型的英文字段名称转换为显示注释
PowerDesigner 中把Name值批量复制到Comment实用脚本,注意是在CDM和PDM中运行此脚本便可.PowerDesigner->Tools->Execute Commands->Edit/Run Scripts
在使用PowerDesigner对数据库进行概念模型和物理模型设计时,一般在NAME或Comment中写中文,在Code中写英文。Name用来显 示,Code在代码中使用,但Comment中的文字会保存到数据库Table或Column的Comment中,当Name...
在数据库设计中,经常使用数据库逆向工程,将数据库中库表结构转为PDM,为了阅读方便,需要将将表字段的comment转换为PDM的name。该文件解决此问题
NULL 博文链接:https://stunizhengjia.iteye.com/blog/2018543
PowerDesigner里执行脚本命令,把name列的内容批量复制到comment列。
>确定 <br>3、从PD菜单选择->Database->Generate Database->在弹出窗口中Tables与Columns下分别选中Comment->在Option标签页下选中Generate name in empty comment->确定 <br>让软件开发快乐起来
在powerdesigner中无法把中英文的字段名同时显示出来,只有通过把中文字段的含义拷贝到stereotype中才行。通过这个脚本文件将自动的把你的数据库中的所有字段的Name拷贝到stereotype中,非常方便。