Posted On: Dec 17, 2020
Constraints are the rules or limits that we can apply to the type of data in a table
The available constraints in SQL are:
NOT NULL: This constraint tells us that we cannot store a null value in a column.
UNIQUE: This constraint when specified with a column, tells that all the values in the column must be unique.
PRIMARY KEY: A primary key is a field that can uniquely identify each row in a table. Typically, used to specify a field in a table as the primary key.
FOREIGN KEY: A Foreign key is a field that can uniquely identify each row in another table.
CHECK: This constraint helps to validate the values of a column to meet a particular condition.
DEFAULT: This constraint specifies a default value for the column when no value is specified by the user.
REATE TABLE Student ( ID int(6) NOT NULL, NAME varchar(10) NOT NULL, ADDRESS varchar(20) );
Never Miss an Articles from us.