Monday, July 7, 2014

Constraints in SQL

Constraints enforce rules at the table level.

Constraints prevent the deletion of table if there are dependencies.

The following constraint types are valid.

- NOT NULL  : A NOT NULL constraint prohibits a database value from being null.

-UNIQUE  : A unique constraint prohibits multiple rows from having the same value in the
           same column or combination of columns but allows some values to be null.

-PRIMARY KEY : Uniquely identifies each row in the table.

-FOREIGN KEY : Establishes and Enforces a foreign key relationship between the column and a column of the referenced table.

-CHECK : Specifies a condition that must me true.


•Name the constraints or the oracle server generates a name by using Sys_Cn format.


• Create a constraint either,at the time the table is created or after the table has been created.

• Define a constraint at the column or table level.

• View constraints in the data dictionary ( USER_CONSTRAINTS )





No comments:

Post a Comment