1 2 3 4 5 6 | CREATE SEQUENCE seqTest INCREMENT BY 1 -- 每次加几个 START WITH 1 -- 从1开始计数 NOMAXvalue -- 不设置最大值 NOCYCLE -- 一直累加,不循环 CACHE 10; --设置缓存cache个序列,如果系统down掉了或者其它情况将会导致序列不连续,也可以设置为---------NOCACHE |
1 | SELECT Sequence名称.CurrVal FROM DUAL; |
1 | select seqtest.currval from dual |
1 | insert into 表名(id,name)values(seqtest.Nextval,'sequence 插入测试'); |
1 | alter sequence SEQTEST maxvalue 9999999; |
1 | DROP SEQUENCE seqTest; |
1 2 3 4 5 6 7 | create sequence SEQ_ID minvalue 1 maxvalue 99999999 start with 1 increment by 1 nocache order; |
1 2 3 4 5 6 7 8 9 10 11 12 13 | create or replace trigger tri_test_id before insert on S_Depart --S_Depart 是表名 for each row declare nextid number; begin IF :new.DepartId IS NULLor :new.DepartId=0 THEN --DepartId是列名 select SEQ_ID.nextval --SEQ_ID正是刚才创建的 into nextid from sys.dual; :new.DepartId:=nextid; end if; end tri_test_id; |
欢迎光临 度量快速开发平台-专业、快速的软件定制快开平台 (http://bbs.delit.cn/) | Powered by Discuz! X3.2 |