打開(kāi)navicat
,新建查詢(xún)(注:“表名和字段名分別改成你需要自增的表名和字段名”)
create sequence 表名_SEQ
minvalue 1
maxvalue 999999999999
start with 1
increment by 1
cache 20
order;
執(zhí)行完上述代碼后,繼續(xù)執(zhí)行
CREATE OR REPLACE TRIGGER 表名_TG
before insert ON SMS.表名
for each row
WHEN (new.字段名 is null)
begin
select 表名_SEQ.nextval into:new.字段名 from dual;
end 表名_TG;