oracle 自增长


1.创建序列
CREATE SEQUENCE SEQ_TEST

minvalue 1

maxvalue 99999999

start with 1

increment by 1

nocache order;

2.创建触发器
CREATE OR REPLACE TRIGGER AUTOINCREMENT
BEFORE INSERT ON TEST
FOR EACH ROW
WHEN (NEW.ID IS NULL)
BEGIN
SELECT SEQ_TEST.NEXTVAL INTO :NEW.ID FROM DUAL;
END;

你可能感兴趣的:(oracle 自增长)