序列:oracle可以通过序列来生成主键
create table Foo (
foo_id number(11),
foo_value varchar2(50),
constraint FOO_PK primary key(foo_id)
)
创建序列DDL
create sequence 序列名
[ start with 数值(10000)]
[increment by 数值]
删除序列DDL
drop sequence 序列名
通过伪列currval获取当前序列值
通过伪列nextval取序列值下一个值
select seq_foo.nextval from dual;
select seq_foo.currval from dual;
insert into foo (foo_id,foo_value) values(seq.foo.nextval,‘clark’);
原文地址:http://blog.csdn.net/clark_xu/article/details/44036929