创建序列
CREATE SEQUENCE myseq; //创建序列
CREATE TABLE testseq(
next NUMBER,
curre NUMBER //当前
)
执行三次
--执行三次 INSERT INTO testseq(next,curre) VALUES(myseq.nextval,myseq.currval) select * from testseq
再次创建序列
DROP SEQUENCE myseq; CREATE SEQUENCE lanpo INCREMENT BY 2; select * from testseq
执行几次
INSERT INTO testseq(next,curre) VALUES(lanpo.nextval,lanpo.currval) select * from testseq
序列从指定的值开始
CREATE SEQUENCE lanpoo INCREMENT BY 2 START WITH 10;
插入五次
CREATE TABLE testseq2(
next NUMBER,
curre NUMBER
)
INSERT INTO testseq2(next,curre) VALUES(lanpoo.nextval,lanpoo.currval)
创建序列使其在1,3,5,7,9循环
CREATE SEQUENCE lanpo3 MAXVALUE 10 START WITH 1 INCREMENT BY 2 CACHE 2 CYCLE ; CREATE TABLE testseq3( next NUMBER, curre NUMBER )
INSERT INTO testseq3(next,curre) VALUES(lanpo3.nextval,lanpo3.currval) select * from testseq3
同义词(了解)
删除
注意:此种特性只适合oracle数据库