WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

SQL Constraints


SQL Constraints

SQL imperatives are utilized to indicate rules for the information in a table.

 If there is any infringement between the limitation and the information activity, the activity is prematurely ended by the constraint.

Constraints can be determined when the table is made (inside the CREATE TABLE proclamation) or after the table is made (inside the ALTER TABLE statement).

SQL CREATE TABLE + CONSTRAINT Syntax

Make TABLE table_name
(
column_name1 data_type(size) constraint_name,
column_name2 data_type(size) constraint_name,
column_name3 data_type(size) constraint_name,
....
);

 In SQL, we have the accompanying constraints:

  • NOT NULL - Indicates that a section can't store NULL value
  • UNIQUE - Ensures that each line for a section must have a one of a kind value
  • PRIMARY KEY - A mix of a NOT NULL and UNIQUE.
  • FOREIGN KEY - Ensure the referential trustworthiness of the information in one table to coordinate qualities in another table
  • CHECK - Ensures that the incentive in a section meets a explicit condition
  • DEFAULT - Specifies a default an incentive for a column