In many databases there is a data type called an automatic growth column. Almost all relational databases support the operation of automatic growth columns, but only Oracle is special, he only provides an automatic growth column after the Oracle 12C version, none of which has been done before, and all similar operations must be handled in a sequential fashion.
a version prior to Oracle 12C can only be handled manually.
* * The creation syntax of the sequence * * Create
SEQUENCE sequence name;
[INCREMENT by step] [Start with start value]
[MAXVALUE max value | Nomaxvalue]
[MinValue min | Nominvalue]
[CYCLE | Nocycle]
[Cache Caching Data | NoCache]
In most cases, only default sequences are created when using a sequence
Create a default sequence seq:
CREATE SEQUENCE seq;
The default sequence is a minimum value of 1, no maximum, starting value of 0, and 20 cached data set
To view the sequence properties:
SELECT * from User_sequences;
Information for the query to SEQ:
Sequence name (sequence_name): seq
Sql> SET linesize 300;
sql> SET PAGESIZE 30;
Sql> SELECT * from User_sequences;
Name of the sequence_name sequence: seq
Min_value Minimum Value: 1
Max_value max value: 1.0000E+28
increment_by Step Size: 1
CY Loop: N
OR
Cache_size Cache 20
Last_number Last content 1
So now that the sequence has been created, and then you need to use this sequence, you can use two pseudo column operations for a sequence:
The object of the sequence. Nextval: Represents the growth of the sequence, with each invocation, the sequence plus the specified step size;
The object of the sequence. Currval: Means to get the current sequence content, regardless of how it is invoked, the contents of the sequence do not change