It is mainly 2 points. First, createSequence;
Then, when the insert statement is run, the position of the auto-increment field is writtenSequence name. nextval.
The following describes how to create a table, then create a sequence, and write an insert statement to add a field.
1. Create a table first
Create table "FLOWCAL "."T_USERINFO"
("C_ID"NUMBER (*, 0 ),
"C_USER" VARCHAR2 (20 BYTE ),
"C_PASSWORD" VARCHAR2 (20 BYTE ),
"C_ROLE" VARCHAR2 (20 BYTE ),
"C_COMMENT1" VARCHAR2 (20 BYTE ),
"C_COMMENT2" VARCHAR2 (20 BYTE)
)
Now I want to add C_ID.
2. Create an Oracle sequence. The SQL statement is as follows:
Create sequence name
Increment by 1
Start with 1
Max value 999999999
Cycle;
Create a sequence with a minimum value of 1 and a serial number with a maximum value of 999999999 to automatically cycle
Below is my sequence, as shown below:
CREATE SEQUENCE"FLOWCAL". "SEQ_USERINFO"
MINVALUE 0
Max value 9999999999999999999999999999
Increment by 1
Start with 24
CACHE 20
ORDER
CYCLE;
3. PassSequence name. nextvalDuring insertion, the Field Auto-increment is 1.
When inserting data into a table, the SQL statement is written as follows:
SQL>Insert into table name values (, column 1 value, column 2 value ,....);
"Sequence name" can be replaced with the name you need.
The following is my insert statement:
Insert into T_USERINFO values (SEQ_USERINFO.NEXTVAL, '11', '11', '11', '11', '11 ')
The following is an image for your reference: