A: 右键 PDM模块 →List Of →Tables,弹出List of Tables 对话框, 左侧的序列号表明Table 的个数。html
选中准备编辑的表,【右键】->【Properties】->【Columns】->【Customize Columns and Filter】->【Comment】->【OK】
或使用快捷键
【右键】->【Properties】->【Columns】->【Ctrl+U】->【Comment】->【OK】 mysql
PowerDesigner中Table视图同时显示Code和Name,像下图这样的效果:sql
实现方法:Tools-Display Preference数据库
从数据库里抽取了数据模型,为了理清思路,须要将name改成中文名称,可是pd自动将name填充为code,能够经过以下配置修改: post
选择tools->general Options spa
选择弹出窗口中的Dialog选项,将Name to Code mirroring 上的钩去掉。.net
进入PowerDesigner,打开一个PDM,在菜单栏找到:Tools – Excute Commands – Edit/Run Script,或者直接按Ctrl+Shift+X调出脚本执行窗口,输入下边的代码就能够了。使用的是VBScript,语义比较容易理解,能够根据本身的需求修改。3d
打开模型 Tools-->Execute Commands --> Edit/Run Scriptcode
UCase大写 LCase小写htm
输入如下语句(根据实际状况可作相应调整):
Option Explicit ValidationMode = True InteractiveMode = im_Batch Dim mdl ' 当前模型 ' 获取当前模型 Set mdl = ActiveModel If (mdl Is Nothing) Then MsgBox "没有打开一个模型" ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then MsgBox "当前模型不是一个PDM" Else '调用处理程序 ProcessFolder mdl End If '调用的处理程序 Private sub ProcessFolder(folder) Dim Tab '要处理的表 for each Tab in folder.Tables ' if not Tab.isShortcut then ' Tab.code = tab.name '表名处理,前边添加前缀,字母小写 Tab.name= UCase(Tab.name) Tab.code= UCase(Tab.code) Dim col ' 要处理的列 for each col in Tab.columns '列名称和code所有小写,大写诗UCase col.code= UCase(col.code) col.name= UCase(col.name) next 'end if next ' 处理视图 ' Dim view 'running view ' for each view in folder.Views ' if not view.isShortcut then ' view.code = view.name ' end if ' next ' 递归进入 sub-packages Dim f ' sub folder For Each f In folder.Packages if not f.IsShortcut then ProcessFolder f end if Next end sub
使用说明: 在【Tools】-【Execute Commands】-【Edit/Run Script】 下。输入下面你要选择的语句便可,也能够保存起来,以便下次使用,后缀为.vbs。
须要注意的问题是:运行语句时必须在Module模式下,若是是导出报表时执行会出现错误提示。
1.Name转到Comment注释字段。通常状况下只填写NAME,COMMENT能够运行语句自动生成。
将该语句保存为name2comment.vbs
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 code 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 Dim col 'running column for each col in tab.columns If (col.comment="") Then '已存在的comment则不更新 col.comment= col.name end if 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中,comment2name.vbs 实习互换。语句为:
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
Oracle版本
总的来讲须要创建序列,并把这个序列赋给某一列,重建触发器便可。
第一步,打开PD,新建一个PDM文档,而后新建一个表,如图所示:
第二步,建立一个序列。在【Model】-【Sequence】打开序列列表窗口,新建一个序列。而后打开序列的属性设置项【physical Options】,进行以下设置,点击肯定,序列创建完毕。
第三步,将刚刚建立的序列应用到表的主键列中。如图所示:点击肯定,此时还没结束,关键一步,要重建触发器。
第四步:重建触发器,在【Tools】下如图,点击
点击肯定,至此,自动建立了一个触发器,把序列的值添加到主键中。
MySql版本
选中UserId单击右键选择Properites
将Identity选中便可
也能够经过下图让自增加属性显示出来。
员工表以下,先将id设置主键:
如今将"员工id"设置惟一约束:
1,切换到"Keys",发现已经存在一个Key1,这个是刚刚新增主键id。在Key1下发空行出,点击会新增一个Key2:
2,双击Key2,在Constraint name输入惟一约束的名字,通常命名方式:UNQ_表名_字段名
3,切换到Columns,选择员工id字段,点击OK:
4,这一步很关键:切换到MySQL,选择Unique key(若是不选择此项,员工id会和id一块儿成为联合主键)
生成后的表结构以下面:
1. 建立一个学生表(Student),包含学号Sno,班级号Sclass,姓名Sanem。
2. 下面为班级号建立索引。选择Indexes标签页,而后点击新增一行来添加索引,而后点击应用保存。
3. 打开索引的属性视图进行修改索引信息,将其名称改成index_class
4. 在索引的属性视图选择columns标签页,添加索引列。选择班级号Sclass列。而后点击OK来确认添加。
5. 可经过索引列的Sort属性来修改索引列的排序方式。
6. 在第三步 属性视图 中,可经过页面下方的Unique属性控制索引是否为惟一索性,经过Cluster属性控制索引是否为簇索引。
7. 预览下建立索引脚本以下
http://www.cnblogs.com/netsql/archive/2010/05/24/1742734.html
https://www.cnblogs.com/ShaYeBlog/p/4067884.html
https://blog.csdn.net/swazer_z/article/details/51197823