Create a table
1 Create TableVacationsday2 (3Fldid Number( A) not NULL,4Fldnamevarchar2( $),5 fldbegindata Date,6 fldenddata Date,7Fldselectid Number(Ten)8);
Create sequence self-increment
1 create SEQUENCE vacationsday_sequence 2 INCREMENT by 1 -- add several 3 START with 1 -- starting from 1 count Span style= "COLOR: #008080" >4 nomaxvalue -- 5 nocycle -- keep accumulating, not looping 6 CACHE 100 ;
Create a Trigger
Create or Replace TriggerVacationsday_trigger--Users_trigger Trigger NameBeforeInsert onVacationsday--users is the table name forEach rowDeclareNextID Number;beginIF: New.fldid is NULL or: New.fldid=0 Then --userid is a column nameSelectVacationsday_sequence.nextval--User_sequence is exactly the sequence you just created. intoNextID fromSys.dual;:new.fldid:=NextID;End if;EndUsers_trigger;
Oracle Build table [self-increment sequence]