Since Oracle was used in the project for the first time. Ah, I am ashamed to be troubled by the problem of an auto-increment column for a long time. This is easy to use without SQL Server. Oracle needs to use auto-incrementing SEQUENCE and trigger.
1. To CREATE a SEQUENCE, you must first have the create sequence or create any sequence permission.
For example:
Create sequence s_id increment by 1 start with 1 MAXVALUE 999999999;
Create sequence s_id NOMAXVALUE NOCYCLE
-- Increment by 1 -- add several
-- Start with 1 -- count from 1
-- NOMAXVALUE -- do not set the maximum value
-- NOCYCLE -- always accumulate without repeating
-- CACHE 10;
After the SEQUENCE is defined, you can use s_id.CURRVAL to obtain the current SEQUENCE value, and use s_id.NEXTVAL to obtain the added SEQUENCE value.
2. Create the before insert trigger for the table and use the SEQUENCE
Create or replace trigger myTrigger
Before insert on myTable
Referencing old as old_value new as new_value
For each row
Begin
New_value.userid = s_id.nextval;
End;
Of course, a trigger can also be called directly when data is inserted.