标签:
-- Create sequence create sequence INNERID minvalue 1 maxvalue 99999999999999 start with 1 increment by 1 cache 20 order;
2.--INNERID.currval 指当前序列 --INNERID.nextval 指下一个序列
create table admin (id varchar2(20),name varchar2(10));
insert into admin values (INNERID.nextval,‘a‘); insert into admin values (INNERID.nextval,‘b‘); insert into admin values (INNERID.nextval,‘c‘); insert into admin values (INNERID.nextval,‘d‘); --不断的插入序列的下一个值.
3.创建触发器(注意这里无法设置id的默认值为INNERID.nextval )
CREATE OR REPLACE TRIGGER admin_tg --admin id 的触发器 BEFORE INSERT ON admin FOR EACH ROW BEGIN SELECT INNERID.NEXTVAL INTO :NEW.id FROM DUAL; END;
测试语句
insert into admin (username) values ( ‘zdz‘);
标签:
原文地址:http://www.cnblogs.com/outlooking/p/4265001.html