Default


Default Constraints is used to specify the constant value for a column. and the user does not need to insert the value for such a column.
If one wants to set the DEFAULT value to the value of the column then DEFAULT constraints is used.

Example : Let's see how to create Default constraint in table.

Query :

CREATE TABLE students


(


Id int(5) NOT NULL,


Name varchar(50) NOT NULL,


Address varchar(50),


City varchar(50) DEFAULT 'Meerut'


);

Output : 

The following SQL create a new table called students and four columns. here the city column is set to 'Meerut' by DEFAULT. so in case the insert into statement does not provide a value for this column, then by default this column would be set to 'Meerut'.