序列: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’);