Here is the syntax to create a sequence. This can be used to create primary keys or to generate a number sequence.
The below sequence will start with 1 and increment by 1. There is no MAXVALUE defined so the sequence’s max value will default to 999999999999999999999999999. The CACHE is set to 50 so it will cache up to 50 values to help with performance.
CREATE SEQUENCE SOME_SEQUENCE
MINVALUE 1
START WITH 1
INCREMENT BY 1
CACHE 50;
To use the above sequence, you can use the <sequence name>.nextval in a statement.
Example:
insert into temp (some_number) values (some_sequence.nextval);