What are MySQL constraints?
As we know that constraint is a kind of limitation or restriction. Similarly, MySQL constraints are used to define some rules that limit the data that can go into a table. With the help of constraints, we can basically maintain the accuracy and integrity of the data inside the table.
Types of MySQL constraints
MySQL constraints are of two types −
- Column Level constraints − The constraints which are applied only to a particular column of the table and limits only column data are called column level constraints.
- Table Level constraints − The constraints which are applied to the whole table and limits whole table data are called table-level constraints.
Followings are some most common MySQL constraints −
- NOT NULL
- PRIMARY KEY
- FOREIGN KEY
Published on 16-Feb-2018 16:12:46