Flat 10% & upto 50% off + 10% Cashback + Free additional Courses. Hurry up

What is Constraint in SQL?

Constraints are the rules applied on data columns on table. These are used to bound the type of data that can go into a table. This ensures the accuracy and consistency of the data. If there is any violation between the constraint and the data action, the action is aborted by the constraint.

Watch this SQL Constraints Video

SQL Constraints can be specified when the table is created or after the table is created.

SQL Constraints could be column level or table level. Column level constraints are applied only to one column, whereas table level constraints are applied to the whole table.

Constraints in SQL

Some of the commonly used Constraints in SQL are:

  • Not NULL Constraints in SQL
  • UNIQUE Constraints in SQL
  • PRIMARY KEY Constraints in SQL
  • FOREIGN KEY Constraints in SQL
  • CHECK Constraints in SQL
  • DEFAULT Constraints in SQL

  • Not NULL:

It indicates that the column cannot have null value.


It ensures that all the values in the column are unique.


It is a key which helps you to find the data from the table. It must be unique and not null.


A foreign key is a field in a relational table that matches the primary key column of another table.


It checks whether all values meets the specific condition or not.


It provides the default value when the value is not specified.


CREATE TABLE table_name


Column1 datatype (size) constraint_name,

Column2 datatype (size) constraint_name,

Column3 datatype (size) constraint_name,


Previous Next

Download Interview Questions asked by top MNCs in 2019?

"0 Responses on Constraints in SQL - Check and Default Constraints in SQL"

    100% Secure Payments. All major credit & debit cards accepted Or Pay by Paypal.

    Sales Offer

    Sign Up or Login to view the Free Constraints in SQL - Check and Default Constraints in SQL.