Home > SQL, Technical > Add constraints to the existing column in Oracle

Add constraints to the existing column in Oracle

July 27, 2012

Syntax: ALTER TABLE TABLE_NAME MODIFY COLUMN_NAME CONSTRAINT

Example 1: ALTER TABLE ORDERS MODIFY O_CODE PRIMARY KEY;

Example 2: ALTER TABLE ORDERS MODIFY O_CODE CONSTRAINT PK_NEW1 PRIMARY KEY;

Example 3: ALTER TABLE ORDERS ADD CONSTRAINT PK_NEW1  PRIMARY KEY(O_CODE);

Example 4: ALTER TABLE ORDERS ADD CONSTRAINT PK_NEW1  PRIMARY KEY(O_CODE,SALES_CODE);

Example 4: ALTER TABLE ORDERS ADD CONSTRAINT CHK_NEW1  CHECK(SALES_CODE>=1000);

 

 

Advertisements
Categories: SQL, Technical
%d bloggers like this: