1. Unique Constraint: When we place UNIQUE constraint on any column.It will not allow duplicate values but it allows single null value.
2. NOt null Constraint: When we place NOT NULL constraint on any column,it will not allow any null values. Entering value for that column is mandatory.
3. Primary Key Constraint: It is a combination of UNIQUE + NOT NULL + CLUSTERED INDEX.
It means when we place PRIMARY KEY constraint on any column then it will not any duplicate values and it does not accept any null values mean time the data in that column will be arranged in ascending order due to CLUSTERED INDEX.
4. Check Constraint: It is used for evaluating range condition. It will check values provided for column. Like salary should greater than 5000 and less than 40000.
5. Foreign Key Constraint:
a. Foreign Key must be Primary Key.
b. Foreign Key can accept duplicate values and Null values.
c. Foreign Key has to take the values from its corresponding Primary Key.
6. Default Constraint: It is useful to insert to default value into a column when user will not provide any value while inserting the data into the table.
Very Improtant Tips or Note:
1. Only one PRIMARY KEY is allowed per table.
2. PRIMARY KEY table is called parent table and FOREIGN KEY table is called child table.
3. While providing FOREIGN KEY we should have to give the reference of its corresponding PRIMARY KEY.
No comments:
Post a Comment