16 September 2013

SQL Constraints


Constraints are the rules enforced on data columns on table. These are used to limit the type of data that can go into a table. This ensures the accuracy and reliability of the data in the database.
Contraints could be column level or table level. Column level constraints are applied only to one column where as table level constraints are applied to the whole table. 

Following are commonly used constraints available in SQL:

  1.      NOT NULL Constraint: Ensures that a column cannot have NULL value.
  2.      DEFAULT Constraint : Provides a default value for a column when none is specified.
  3.      UNIQUE Constraint: Ensures that all values in a column are different.
  4.      PRIMARY Key: Uniquely identified each rows/records in a database table.
  5.      FOREIGN Key: Uniquely identified a rows/records in any another database table.
  6.      CHECK Constraint: The CHECK constraint ensures that all values in a column satisfy certain conditions.
  7.       INDEX: Use to create and retrieve data from the database very quickly.



·    





No comments:

Post a Comment