The relevant Oracle Database Sequence information is as follows:
Create Sequence syntax
Create sequence <schema>. <table_name> _ s
Increment by 1
Start with 1
Max value 99999999999999999999
Minvalue 1
Nocycle;
Where:
Incerment: value added each time
Start: Sequence start value
Maxvalue: Maximum Sequence Value
Nocycle: When the Sequence reaches the maximum value, it does not start with the same Sequence.
Get the next Sequence Value
Select <Sequence_name>. nextval [@ db_link]
From dual;
Query the current Sequence Value
Syntax 1:
Select <Sequence_name>. currval [@ db_link]
From dual;
Mark: If "Current DB Session" has not executed nextval, run currval first.
ORA-08002: sequence DB_SESSION_ID.CURRVAL is not yet defined in this session error.
Syntax 2:
Select last_number-1
From all_sequences
Where sequence_name = '<Sequence_name> ';
Modify Sequence
For example, Alter Sequence <Sequence_name> MaxValue 999999999999999;
Notes
1) Sequence cannot be directly used after "equation: =". For example, vID: = tomSeq. nextval;
2) Sequence can be directly used in "SQL". For example: insert into tomTable values (tomSeq. nextval ,...);