CONSTRAINTS on SQL


These are the objects used to validate the data entry in tables columns.

-TYPES OF CONSTRAINTS:---
-1)Primary key:-Checks for duplicate and null values.

-Primary key can be defined for single or composite columns.

One Primary key per table.

2)Unique key:-checks for duplicate values. One null value is allowed.

3)Check:-The data must obey the rules of comparison operators(=, < ,> ,<=,>=, in

between, like).

4)Rules:-They are like the check constraints but have certain differences.

-Check constraints are applied with the column definitions.

Rules are created separately  and then can be attached with different columns of

different tables.

Check constraints check for existing data, rules do not check for the existing

data.

5)Not Null:-we have to enter the values on the columns where not null constraint

is defined.

6)Foreign key:--Used for Referential integrity:-

-If we insert a particular data in a table column, then matching data should be

inserted  in the column where the foreign key is defined. The Foreign key will

check for data by referencing the column where data is inserted.

The referenced column must have primary key or unique key associated with it.

Constraints can be created using the Create Table or alter table clause.

-Candidate keys:--
--These are a set of columns used to uniquely identify

the rows.The first will be a primary key.

other keys are known as alternate keys

-eno ,  ename, hiredate, salary

-(eno,ename):primary key(composite)
CONSTRAINTS on SQL Reviewed by Rupesh on 12:52 Rating: 5

No comments:

All Rights Reserved by Technology from Developers Eye © 2014 - 2015
Powered By Blogger, Designed by Aadics
Disclaimers:: The information provided within this blogsite is for general informational purposes only. While we try to keep the information up-to-date and correct, there are no representations or warranties, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the information, products, services, or related graphics contained in this blogsite for any purpose.The author does not assume and hereby disclaims any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from accident, negligence, or any other cause.

Contact Form

Name

Email *

Message *

Powered by Blogger.