标签:before 两种 table color col ora bsp min new
1 create table test_table( 2 ID NUMBER PRIMARY KEY, 3 NAME VARCHAR2(10), 4 NICKNAME VARCHAR2(10) 5 ) 6 7 create sequence SEQ_TEST_TRIGGER 8 minvalue 1 9 maxvalue 999999999999999999999999999 10 start with 1 11 increment by 1; 12 13 create trigger test_trigger 14 before insert on test_table 15 for each row 16 when (new.ID is null) 17 begin 18 select SEQ_TEST_TRIGGER.nextval 19 into :new.ID 20 from dual; 21 end; 22 23 24 create trigger tri_test_id 25 before insert on test_table --S_Depart 是表名 26 for each row 27 declare 28 nextid number; 29 begin 30 IF :new.ID IS NULL or :new.ID=0 THEN --DepartId是列名 31 select SEQ_TEST_TRIGGER.nextval --S_S_DEPART正是刚才创建的 32 into nextid 33 from dual; 34 :new.ID:=nextid; 35 end if; 36 end;
两种create trigger方式,创建完成后,就可以insert数据了
标签:before 两种 table color col ora bsp min new
原文地址:https://www.cnblogs.com/melody7003/p/9299152.html