创建表
1 create table VACATIONSDAY 2 ( 3 fldid NUMBER(22) not null, 4 fldname varchar2(200), 5 fldbegindata date, 6 fldenddata date, 7 fldselectid number(10) 8 );
创建序列自增
1 CREATE SEQUENCE vacationsday_Sequence 2 INCREMENT BY 1 -- 每次加几个 3 START WITH 1 -- 从1开始计数 4 NOMAXVALUE -- 不设置最大值 5 NOCYCLE -- 一直累加,不循环 6 CACHE 100;
创建触发器
create or replace trigger vacationsday_trigger --users_trigger 触发器名称 before insert on vacationsday --users是表名 for each row declare nextid number; begin IF :new.fldid IS NULL or :new.fldid=0 THEN --userid是列名 select vacationsday_Sequence.nextval --user_Sequence 正是刚才创建的序列 into nextid from sys.dual; :new.fldid:=nextid; end if; end users_trigger ;