SQL constraints are used to apply specific rules on data present in table. if any rule applied by data is violated then constraints will abort that data action. at the time of defining of table constraints can be applied or at the time of after the table then constraints can be applied. in SQL, constraints are of following types -
1. NOT NULL :- it shows that a column doesn't keep any null value.
2. UNIQUE :- it shows that a unique vale is stored in column of every row.
3. PRIMARY KEY :- it is a group of column or column which preserves unique value and doesn't store NULL value. with its help every records of table are obtained in unique form in other words, we can say that -
"PRIMARY KEY is combination of unique and NOT NULL constraints."
example :- enrollment number for student table, account number for bank customer etc.
4. FOREIGN KEY :- given reference key of any table into another table is foreign key. by FOREIGN KEY, referential integrity of data are maintained. it means a value of FOREIGN KEY is value of which are in previous table. duplicate value of FOREIGN KEY may be NULL.
example :- PRIMARY KEY of student table, enrollment no. is FOREIGN KEY of examination, sports, department and fees table.
5. check constraints :- check constraints is used for applying any specific condition on any column. for example- check balance >=500, check mobile number like "+91%".
6. default :- it represents default value when no value is provided in column.
Subscribe to:
Posts (Atom)
Nested SQL Query or SQL Sub Query in hindi in english
if a SQL query is used inside another SQL query then this type of SQL query is called sub-query. यदि किसी SQL क्वेरी का उपयोग, किसी अन्य SQ...
-
if a SQL query is used inside another SQL query then this type of SQL query is called sub-query. यदि किसी SQL क्वेरी का उपयोग, किसी अन्य SQ...
-
Characteristics / Advantages of Normalisation :- After successful completion of normalisation proces resultant relation R Shows following ...
No comments:
Post a Comment