Automatically including unique sequence numbers during an INSERT. : Sequence Value « Sequence « Oracle PL / SQL






Automatically including unique sequence numbers during an INSERT.

 

SQL>
SQL> create sequence mySeq start with 1000 increment by 1 cache 100;

Sequence created.

SQL>
SQL> create table myTable (col1 number primary key);

Table created.

SQL>
SQL> insert into myTable values (mySeq.nextval);

1 row created.

SQL> insert into myTable values (mySeq.nextval);

1 row created.

SQL>
SQL> select * from myTable;



      COL1
----------
      1000
      1001

2 rows selected.

SQL>
SQL> drop table myTable;

Table dropped.

SQL>
SQL> drop sequence mySeq;

Sequence dropped.

   
  








Related examples in the same category

1.Use sequence in insert command
2.Sequence current value and next value
3.Get Sequence next value
4.Sequence max value: 999999999999999999999999999
5.Set sequence max value
6.Use Sequence in a procedure
7.If new value is null use the value from a sequence
8.Random value based on sequence