None of the previous versions of Oracle 12c are self-contained, and if you need to use a self-add column, you need to sequence.
DROP TABLE CustomerOrder PURGE; CREATE TABLE CustomerOrder ( ORDERID number is not NULL, PRODUCTID number, PRODUCTNAME VARCHAR2 (50), CONSTRAINTS Pk_orderid PRIMARY KEY (ORDERID) ); DROP SEQUENCE Sq_orderid; CREATE SEQUENCE Sq_orderid START with 10000000000000; |
The above code creates a commodity purchase table, and a sequence with a starting number of 10000000000000.
The Nextval method must be called before it can be used immediately after the sequence has been successfully created for the first time.
SELECT Sq_orderid. Nextval from DUAL; |
You can then use the sequence to set values for the table data:
INSERT into CustomerOrder (orderid,productid,productname) VALUES (Sq_orderid. nextval,888, ' Nice '); INSERT into CustomerOrder (orderid,productid,productname) VALUES (Sq_orderid. nextval,999, ' Jie Rou '); |
Self-increment-sequence-sequence in Oracle