Posts

Showing posts from 2021

Constraints in SQL

Image
  Constraints In SQL: Constraints are the rules that must be followed to enter data in the table. The constraint is just like a check that is applied to ingoing and outgoing of data in the table. It is used to check that which types of data would be entered in the table. The data that violates the constraint can’t be entered in the table. A constraint can be defined in two ways table level and column level . Table level constraint can be applied to the whole table and column level constraint can be applied to the specific column. How to apply constraint: We can apply constraint at the time of creating a table using CREATE TABLE keyword. If we want to change the constraint after applying it then we can perform updation through ALTER TABLE   statement. Syntax of Constraints at Column Level :   CREATE   TABLE   table_name  (      column1 datatype   constraint ,      column2 datatype   constraint ,      column3 datatype   constraint    ); Syntax of Constraints at Table