PL/SQL 數據表id自增

第一步 創建一個觸發器

 create or replace trigger HBHJ_AREANOISE_INSERT before insert on HBHJ_AREANOISEDATA for each row
begin
     select SEQ_HBHJ_AREANOISEDATA.NEXTVAL INTO :new.ID from dual;
end; 
第二步 創建一個序列

 -- Create sequence 
create sequence SEQ_HBHJ_AREANOISEDATA
minvalue 1
maxvalue 9999999
start with 1
increment by 1
cache 20; 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章