Enforcement of Primary Key Constraints

An anonymous PRIMARY KEY constraint on the column ID:


SQL> CREATE TABLE myTable
  2  (ID   NUMBER PRIMARY KEY,
  3   NAME VARCHAR2(20)
  4  );

Table created.

SQL>

Give constraint a name:


SQL> CREATE TABLE myTable
  2  (ID   NUMBER CONSTRAINT ID_PK PRIMARY KEY,
  3   PORT_NAME VARCHAR2(20)
  4  );

Table created.

SQL>
Home »
Oracle »
Table » 

Primary Key:
  1. Enforcement of Primary Key Constraints
  2. Composite Primary Keys
  3. ORA-00001: insert a row with a duplicate value for a primary key
Related: