Let Oracle realize self-increasing fields

xiaoxiao2021-03-06  59

First build a sequence, then build a trigger implementation!

CATA0 is a table name, and cata0_id is a field that needs to increase!

Create sequence seq_cata0

INCREMENT BY 1

START WITH 1

MaxValue 9999999

/

Create Trigger TRG_CATA0 BEFORE

INSERT on cata0

For Each Row Begin

SELECT SEQ_CATA0.NEXTVAL

INTO: New.cata0_id

From Dual;

END TRG_CATA0;

转载请注明原文地址:https://www.9cbs.com/read-83834.html

New Post(0)