--Create sequence Create sequence Innerid minvalue 1 maxvalue 99999999999999 start with 1 increment by 1 cache order;
2.--innerid.currval refers to the current sequence--innerid.nextval refers to the next sequence
CREATE TABLE admin (ID varchar2 (), name VARCHAR2 (10));
Insert into admin values (innerid.nextval, ' a '); Insert into admin values (innerid.nextval, ' B '); Insert into admin values (innerid.nextval, ' C '); Insert into admin values (innerid.nextval, ' d '); --constant insertion of the next value of the sequence.
3. Create a trigger (note that the default value for ID cannot be set here is Innerid.nextval)
CREATE OR REPLACE TRIGGER admin_tg--admin ID of the trigger before INSERT on admin for each ROW BEGIN SELECT Innerid. Nextval INTO:NEW.id from DUAL; END;
Test statement
Insert into admin (username) VALUES (' Zdz ');
Set up an auto-growing identity column for a table in Oracle