First step: Create a self-growing sequence
CREATE SEQUENCE zh_alarm_info_seq--Auto-Grow column
INCREMENT by 1--add a few each time
Start with 1-counting starting from 1
Nomaxvalue--Do not set the maximum value
Nocycle--keep accumulating, not looping
NOCACHE--Do not build buffers 3. Create a trigger:
Step two: Create a trigger for a table with a self-growing field, based on the sequence created in the first step
CREATE OR REPLACE TRIGGER trigger_zh_alarm_info
Before INSERT on Zh_alarm_info
For each row
When (NEW. AID is NULL)
Begin
Select Zh_alarm_info_seq. Nextval into:new. AID from dual;
End
Attachment:
Prerequisites for creating a sequence: the self-growing field must be a large write segment
Sequence Query
Select Zh_alarm_info_seq.nextval from Sys.dual;
Sequence deletion
DROP SEQUENCE Zh_alarm_info_seq
Oracle Add self-growing field method steps