oracle建表利用序列和触发器使得id自增长

1:oracle的id自动增长一般是通过序列实现的,跟建表的语句没有关系!

比如你要建一张person表,属性有id,name,age。此时你想把id设置为自增长。

create sequence emp_id
minvalue 1
maxvalue 999999999999999999999999999
start with 1
increment by 1
nocache;

然后每次insert的时候
insert into person values
(person_id.nextval, ...) 就实现了自动增长
相关:http://www.cnblogs.com/foura/archive/2010/11/24/1886165.html
http://hi.baidu.com/kocokolo/item/bcf64ab8ece46feb4fc7fd4b
posted @ 2012-12-03 13:28  歌颂者  阅读(187)  评论(0编辑  收藏  举报