Oracle self increment of auto increment or identification field establishment method

  • 2020-06-07 05:28:20
  • OfStack

The following is an implementation of ORACLE in two steps:
1. Establishment of SEQUENCE CREATE [OR REPLACE] SEQUENCE sequence_identity START initial seed INCREMENT BY step upper bound [NOMAXVALUE] NOCYCLE [empty]
2. Establish TRIGGER CREATE [OR REPLACE] TRIGGER trigger_identity BEFORE INSERT ON EACH EACH ROW sequence_identity. END;
In order to avoid the collision of sequence with the same name as far as possible, sequence_identity naming method is recommended
The form of SEQ_UserName_TableName_SequenceName
trigger_identity, same as above.

Related articles: