1. 建立 SEQUENCE CREATE [ OR REPLACE ] SEQUENCE sequence_identity START WITH initial seed INCREMENT BY step MAXVALUE upper bound [NOMAXVALUE] NOCYCLE [empty]
2. 建立 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;
说明:
为了尽量避免 sequence 同名冲突, sequence_identity 命名方式,建议采取
SEQ_UserName_TableName_SequenceName 的形式
trigger_identity 的命名方式,同上。 猜你喜欢