MySQL Constraints
Rules for data.
MySQL Constraints
SQL constraints are used to specify rules for the data in a table.
Constraints are used to limit the type of data that can go into a table. This ensures the accuracy and reliability of the data.
Common Constraints:
NOT NULL- Ensures a column cannot have a NULL valueUNIQUE- Ensures all values in a column are differentPRIMARY KEY- A combination of a NOT NULL and UNIQUEFOREIGN KEY- Prevents actions that would destroy links between tablesCHECK- Ensures that the values in a column satisfy a specific conditionDEFAULT- Sets a default value for a column if no value is specifiedCREATE INDEX- Used to create and retrieve data from the database very quickly