Once the table is created, then the user can add any value in the table, but the values have to be validated. In this case, the constraints act as a validator which checks the data validity.

There are five types of constraints:-
  • NOT NULL:-The column will not accept the NULL value
  • UNIQUE:-It will check whether the record entered is unique or not.
  • PRIMARY:-The column will have a value, and it will be unique. In a table, only one primary key should be there.
  • CHECK:-when the user wants the record in the column to be of a particular type.
  • FOREIGN KEY:-to relate more than one table that means matching the value of one table with that of another table.
BY Best Interview Question ON 19 Feb 2019