disable primary key constraint in oracle code example

Example 1: add primary key constraint in oracle

-- Adding Using alter
ALTER TABLE table_name
ADD CONSTRAINT constraint_name PRIMARY KEY (column1, column2, ... column_n);

Example 2: oracle create table auto generated primary key

-- For oracle 12c or later 
-- auto inc
create table t1 (
    c1 NUMBER GENERATED by default on null as IDENTITY,
    c2 VARCHAR2(10)
    );
-- More options for initial value and increment value
create table t1 (
    c1 NUMBER GENERATED ALWAYS as IDENTITY(START with 1 INCREMENT by 1),
    c2 VARCHAR2(10)
    );

Tags:

Sql Example