Sunday, June 28, 2015

What is constraint?

What is constraint:

Constraints are used to limit the type of data that can go into a table. There are five types of constraints:
v  Primary key
v  Unique Key
v  Foreign Key
v  Not Null
v  Check

Primary key: In a database table, the Primary Key is a column which has a unique value for each of the row within that column. It can’t have NULL value. Primary key in one table can be Foreign key in other table.

Foreign key: Foreign key is the key that make a link with other table. It can’t have NULL value. Foreign key in one table can be primary key in other table.

Unique key: In a database table, the Unique Key is a column which may or may not have null value of each of the row within that column.

Not Null: This means the column should always put the value. It can’t be Null.

Cheek: Limit the value range that can be placed in a column.


No comments:

Post a Comment