powerdesigner 遇到的各种问题总结
1. 设置自增
打开表 -- 在具体列的前面双击即可添加各种属性
2. 生成sql 时设置编码
database --> generate database --> format --> encoding
3. 生成sql 时name作为注释
3.1 1 database --> edit current dbms --> Script--> Object--> Column--> ColumnComment
3.12 将ColumnComment的value改为comment on column [%QUALIFIER%]%TABLE%.%COLUMN% is %.q:COLNNAME%
注: 第二步中有的版本value是有值的,有的版本是空的,我的版本就是空的
3.13 数据库---> Deneration Database --> Format--> 勾选Generate name in empty comment
参考: https://blog.csdn.net/shixun67/article/details/77521076
---- 上面的方法可惜没有解决我的问题, 下面是我采用的方法
3.2 Tools->Execute Commands->Edit/Run Scripts,执行下面的脚本
'把pd中那么name想自动添加到comment里面 '如果comment为空,则填入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 ' 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 if trim(tab.comment)="" then '如果有表的注释,则不改变它.如果没有表注释.则把name添加到注释里面. tab.comment = tab.name end if Dim col ' running column for each col in tab.columns if trim(col.comment)="" then '如果col的comment为空,则填入name,如果已有注释,则不添加;这样可以避免已有注释丢失. col.comment= col.name end if next end if next Dim view 'running view for each view in folder.Views if not view.isShortcut and trim(view.comment)="" 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
然后可以将脚本保存为 name2comment.vbs(我保存了)
参考1:https://www.cnblogs.com/xujingyang/p/9071820.html
参考2: https://www.cnblogs.com/telwanggs/p/7698260.html
4. 有些很复杂的外键删除
1. 首先可以只删除symbol(Delete Symbols only))
2. 左边的工作空间里有References, 所有的外键可以在这儿编辑和删除
5. 设置字符集和存储引擎
第一种方法:
1.1. Database => Edit Current DBMS => Mysql5.0 => Script => Objects => Table => Options
1.2. 在右边的Value框内最后部分追加:
DEFAULT CHARACTER SET = %s : list = utf8 | gbk, default = utf8