Imitate
1 Createsequence seq_id2MinValue13MaxValue999999994Start with 15Increment by 16 NoCache7 Order;8 9 To create a trigger:Ten One Create Triggertri_test_id--(1) ABeforeInsert onTest forEach row--test is a table name - begin - SelectSeq_id.nextval into: new.id fromdual; the Endtri_test_id; - - Create or Replace Triggertri_test_id--(2) -BeforeInsert onS_depart--S_depart is the table name + forEach row - Declare +NextID Number; A begin at IF: New. Departid is NULL or: New. Departid=0 Then --Departid is a column name - SelectSeq_id.nextval--seq_id is exactly what you just created. - intoNextID - fromsys.dual; -: New. Departid:=NextID; - End if; in Endtri_test_id;
Instance
1 CREATESEQUENCE rsk_book_filter_seq2INCREMENT by 1 3START with 10000 4 Nomaxvalue5 nocycle6 NOCACHE7 8 CREATE OR REPLACE TRIGGERRsk_book_filter_tri9BeforeINSERT onRsk_book_filterTen forEach ROW One BEGIN A SELECTRsk_book_filter_seq. Nextval into: NEW. risk_book_filter_id fromDUAL; - END;
Oracle enables auto-increment functionality