Create a SEQUENCE and retrieve the value : Create Sequence « Sequence « Oracle PL / SQL






Create a SEQUENCE and retrieve the value

 

SQL>
SQL> CREATE SEQUENCE supplier_seq
  2      MINVALUE 1
  3      MAXVALUE 999999999999999999999999999
  4      START WITH 1
  5      INCREMENT BY 1
  6      CACHE 20;

Sequence created.

SQL>
SQL> select supplier_seq.nextval from dual;

   NEXTVAL
----------
         1

SQL> select supplier_seq.nextval from dual;

   NEXTVAL
----------
         2

SQL> select supplier_seq.nextval from dual;

   NEXTVAL
----------
         3

SQL> select supplier_seq.nextval from dual;

   NEXTVAL
----------
         4

SQL>
SQL> drop sequence supplier_seq;

Sequence dropped.

SQL>
SQL>

           
         
  








Related examples in the same category

1.If id is null, use the value from sequence
2.CREATE SEQUENCE myTableIDSeq INCREMENT BY 1 START WITH 1000;
3.Use dual table to check sequence
4.create sequence emps_seq start with 501 increment by 10