powerdesigner 12 生成 mysql注释!

转自:http://ya888g.iteye.com/blog/551466

默认的pd没有生成注释,针对mysql5.0可以如下修改。
在Database–>edit Current DBMS…

设置dbms的属性,找到mysql5.0–>script–>objects–>column–>add

把原来的内容:

%20:COLUMN% [%National%?national ]%DATATYPE%[%Unsigned%? unsigned][%ZeroFill%? zerofill][ [.O:[character set][charset]] %CharSet%][.Z:[ %NOTNULL%][%IDENTITY%? auto_increment:[ default %DEFAULT%]][ comment %.q:@OBJTLABL%]]

 

改为:

%20:COLUMN% [%National%?national ]%DATATYPE%[%Unsigned%? unsigned][%ZeroFill%? zerofill][ [.O:[character set][charset]] %CharSet%][.Z:[ %NOTNULL%][%IDENTITY%? auto_increment:[ default %DEFAULT%]][ comment %.q:COMMENT%]]

 

呵呵,其实只有最后的OBJTLABL改为COMMENT就行了。以前的OBJTLABL不知道指什么,知道的朋友告诉一下。。。

这样生成的代码每个字段就有注释了:

create table code
(
code_id              INTEGER not null comment ‘代码ID’,
code_no              VARCHAR(10) not null comment ‘代码编码’,
code_chinese_name    VARCHAR(50) not null comment ‘中文名称’,
code_english         VARCHAR(50) comment ‘英文名称’,
parent_code_id       INTEGER comment ‘父代码ID’,
code_type            VARCHAR(50) comment ‘代码类型’,
sort_no              INTEGER comment ‘代码序号’,
create_by            INTEGER comment ‘记录创建人’,
create_date          TIMESTAMP comment ‘记录创建时间’,
update_by            INTEGER comment ‘记录更新人’,
update_date          TIMESTAMP comment ‘记录更新时间’,
primary key (code_id)
);
表的注释:

设置dbms的属性,找到mysql5.0–>script–>objects–>Table–>TableComment:

value中,增加如下内容

alter table [%QUALIFIER%]%TABLE% comment %.60qA:COMMENT%

 

增加后就会生成下面语句:

alter table code comment ‘代码表’;

 

代码生成:

点击菜单Database–>generate Database

出现database generation屏幕:在Format tab页中,勾选generate name in empty comment

单击确定就可以生成相应的代码,代码中就会出现上面的注释了。