Sybase Powerdesigner - 如何自动格式化PK和FK的命名?
运行脚本以像这种格式一样格式化主键和外键
PK_TABLENAME
FK_PARENT_CHILD
例子
PK_Post
FK_Post_Comment
Sybase Powerdesigner - 如何自动格式化PK和FK的命名?
运行脚本以像这种格式一样格式化主键和外键
PK_TABLENAME
FK_PARENT_CHILD
例子
PK_Post
FK_Post_Comment
The following solution is complicated, but also very flexible/ not so intrusive. This will get you started:
In your PD model, create a new "Custom check with Autofix Option" for the Table Or Column (Or Reference) metaclass object. (Doesn't matter which you cheoose. You can iterate thru sub-objects in your vbscript code, using nested foreach loops (for each table ... /for each column ...) see below:
click on Menu Item Model / Extended Model Definitions. Click on the blue-white >=== Icon.
Give your new "Extended model definition" a name, e.g. mysql55-custom-001.
Optional: Click on Export Extended Model definition, export it as mysql55-custom-001.xem.
Click on the arrow next to the name of the new extenden model definition, to save it to the default subdir.
This is the extended model dialog:
Right-Click on "Profile", click on "Add Metaclasses..." Check Column
Right Click , Select "New...", Click/Select "Custom Check".
Now add a custom check to your model. you must define a check script (in vbscript), and an autofix script.
Click on "Help" Button, Click on "Defining the Script of a custom check". You'll find a code sample to get you started. It will look like this. But you'll need to adapt the code of course with vbscripts low-level string processing functions.
至少对于外键,您可以创建一个 Initialize 事件处理程序来定义附加表中的名称。当您在图表中创建参考时,它将起作用;当您通过列表创建它时可能不是(因为尚未附加表格)。
我离开作为处理名称冲突的练习......
对于主键,您可以在 Key 元类上使用 Validate 事件处理程序,并在它成为主键时重命名该键(除非它的名称已经以“PK”开头)。