Share on Google+Share on Google+

SQL add column default value

This page discusses - SQL add column default value

SQL add column default value


Add a Column default value is used in SQL, When create statement Query is performed in SQL .Usually, the default value is given to the column ,when no value is inserted to the column .

Understand with Example

The Tutorial understand you a example from SQL add column default value .In this, we create a table Stu_Table using create statement with field name Stu_Class. The '10' in a data type specification indicates a default value for a column. The insert into add the records into the table. The Stu_Class takes the default value of 10,when no value is inserted into table during insert statement operation.

Create Table Stu_Table




create table Stu_Table(Stu_Id integer(2), Stu_Name varchar(15), 
Stu_Class  varchar(10) default '10')

Insert data into Stu_Table

insert into Stu_Table (Stu_Id, Stu_Name) values(1,'Komal');
insert into Stu_Table (Stu_Id, Stu_Name) values(2,'Ajay');
insert into Stu_Table (Stu_Id, Stu_Name) values(3,'Rakesh');
insert into Stu_Table (Stu_Id, Stu_Name) values(4,'Bhanu');
insert into Stu_Table (Stu_Id, Stu_Name) values(5,'Santosh');


Stu_Id Stu_Name Stu_Class
1 Komal 10
2 Ajay 10
3 Rakesh 10
4 Bhanu 10
5 Santosh 10



Posted on: April 18, 2011 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Discuss: SQL add column default value  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image