SQL Server, ACCESS, and MYSQL both have an auto-increment field, which is usually used for primary keys or index keys. However, in ORACLE, this field type is not provided (not actually a field type), but we often need this function.
SQL SERVER, ACCESS, and MYSQL both have an auto-increment field, which is usually used for primary keys or index keys. However, in ORACLE, this field type is not provided (not actually a field type), but we often need this function.
The following shows an implementation method of ORACLE. Two steps are required:
1. create sequence create [or replace] SEQUENCE sequence_identity start with initial seed increment by step MAXVALUE upper bound [NOMAXVALUE] NOCYCLE [empty]
2. create trigger create [or replace] TRIGGER trigger_identity before insert on table_name for each row begin select sequence_identity.NEXTVAL INTO: new. column_name from dual; END;
Note:
To avoid sequence conflicts with the same name, we recommend that you use the sequence_identity naming method.
SEQ_UserName_TableName_SequenceName format
The trigger_identity naming method.