Using a sequence to populate a table's column : Create Sequence « Sequences « Oracle PL/SQL Tutorial






SQL>
SQL>
SQL> CREATE TABLE test (
  2       record_id   NUMBER(18,0),
  3       record_text VARCHAR2(10)
  4  );

Table created.

SQL>
SQL> CREATE SEQUENCE test_seq;

Sequence created.

SQL>
SQL> SELECT test_seq.nextval FROM DUAL;

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

SQL> SELECT test_seq.nextval FROM DUAL;

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

SQL> SELECT test_seq.nextval FROM DUAL;

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

SQL>
SQL>
SQL> INSERT INTO test VALUES (
  2       test_seq.nextval,
  3       'Record A'
  4  );

1 row created.

SQL>
SQL> INSERT INTO test VALUES (
  2       test_seq.nextval,
  3       'Record B'
  4  );

1 row created.

SQL>
SQL> SELECT * FROM test;

 RECORD_ID RECORD_TEX
---------- ----------
         4 Record A
         5 Record B

SQL>
SQL>
SQL> DROP SEQUENCE test_seq;

Sequence dropped.

SQL>
SQL> drop table test;

Table dropped.

SQL>








5.1.Create Sequence
5.1.1.Sequences
5.1.2.Create the simplest sequence
5.1.3.Creating a sequence and then get the next value
5.1.4.Test sequence step
5.1.5.CREATE SEQUENCE test_seq;
5.1.6.Using a sequence to populate a table's column
5.1.7.create sequence deptno_seq start with 50 increment by 10
5.1.8.Create a sequence starting with '100000000 order'
5.1.9.Create a sequence
5.1.10.CREATE SEQUENCE myTableIDSeq INCREMENT BY 1 START WITH 1000;
5.1.11.Create a sequence starting with 1000
5.1.12.create sequence emps_seq start with 501 increment by 10