User Tools

Site Tools


oracle:sql:sequence:using_a_sequence_in_a_table_column:prior_to_oracle_12c

Oracle - SQL - Sequence - Using a Sequence in a Table Column - Prior to Oracle 12c

Prior to Oracle 12c, a sequence can only be associated indirectly with a table column at the insert time.


Create a new table

CREATE TABLE test (
  id NUMBER PRIMARY KEY,
  title VARCHAR2(255) NOT NULL
);

Create a Sequence for the id column of the test table

CREATE SEQUENCE test_id_seq;

Insert data into the test table

INSERT INTO test(id, title)
VALUES(test_id_seq.NEXTVAL, 'A Sequence Value');
 
INSERT INTO test(id, title)
VALUES(test_id_seq.NEXTVAL, 'Another Sequence Value');

Query data from the test table

SELECT id, title
FROM test;

NOTE: The test Table has no direct association with the test_id_seq sequence.

oracle/sql/sequence/using_a_sequence_in_a_table_column/prior_to_oracle_12c.txt · Last modified: 2021/08/11 12:16 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki