失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > oracle 主键列创建自增长 powerdesigner创建oracle 数据库表 设置表主键列为自动增长。 ....

oracle 主键列创建自增长 powerdesigner创建oracle 数据库表 设置表主键列为自动增长。 ....

时间:2019-04-20 21:28:11

相关推荐

oracle 主键列创建自增长 powerdesigner创建oracle 数据库表 设置表主键列为自动增长。 ....

1 在表视图的列上创建。 双击表视图,打开table properties ———>columens , 双击要设置的列(显示列的序号的那个按钮,单击后,会显示横向的黑色箭头)。 打开column properties 对话框。在 ‘general’ 项中, 最下面,找到 sequence,下拉框 后面,有三个按钮就 ‘create’,‘select’,‘properties’。 新建的话就点击‘create' 打开 sequence properties 对话框,general 中的name, code 随意修改 切换到 physical options 项,输入下面几项内容 start with 1 increment by 1 minvalue 1 maxvalue 根据自己需要决定是否要设定。没有的话,选择 no max value no cache 勾选 输入完后,点击应用。创建完毕。在 preview 中 可以看到相应的创建代码 同时,在table properties———>preview 的创建代码中,自动加入了 触发器trigger 的创建代码。 创建完成。 使用:到table properties———>preview 中拷贝table 的创建代码,赋值到plsql中执行。 提示:不知道是我的powerdesigner 设置问题还是怎么回事,table 的创建代码中没有自动加入 sequence 的创建部分。 所以,还要到sequence properties ———>preview 中,把sequence的创建代码拷贝到 表创建的代码中 放到 cteate table .... 和 create trigger ...中间 例如: create table G_EC_LotteryCategory ( lcId NUMBER(3) not null, lcName NVARCHAR2(30), lcAbbr NVARCHAR2(20), constraint PK_G_EC_LOTTERYCATEGORY primary key (lcId) ) / create sequence Sequence_LotCateID increment by 1 start with 1 nomaxvalue minvalue 1 nocache; create trigger tib_g_ec_lotterycategory before insert on G_EC_LotteryCategory for each row declare integrity_error exception; errno integer; errmsg char(200); dummy integer; found boolean; begin -- Column lcId uses sequence Sequence_LotCateID select Sequence_LotCateID.NEXTVAL INTO :new.lcId from dual; -- Errors handling exception when integrity_error then raise_application_error(errno, errmsg); end; / 在plsql 中执行上端代码。创建表; 添加记录测试; insert into G_EC_LotteryCategory(lcName,lcAbbr) values('1','1'); insert into G_EC_LotteryCategory(lcName,lcAbbr) values('2','2'); 查询后,看到的的id列是自动增长的。 2 先创建,然后在列的sequence 项中选择。 在 powerdesigner 左边的树中,你的model 项目的子菜单中有 sequence ,右键点击——> new 打开 sequence properties 对话框,添加内容上面的方法类似。 完场后,还是到表视图中,双击列名,打开column properties 对话框。 general——> sequence 的下拉框中就出现了刚才创建的 sequence ,选中,保存即可。

如果觉得《oracle 主键列创建自增长 powerdesigner创建oracle 数据库表 设置表主键列为自动增长。 ....》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。