SQL Alter Column

SQL Alter Column modifies the existing table and add a column.

SQL Alter Column


SQL Alter Column modifies the existing table and add a column.

Understand with Example

The Tutorial illustrate an example from 'SQL Alter Column'. To understand and grasp this example, we create a table 'Stu_Table'. The create table statement construct a table 'Stu_Table' with field attribute and data type specified in Query respectively. 

Create Table Stu_Table

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

Insert data into Stu_Table

The insert into insert the records or row values into table 'Stu_Table'.

insert into Stu_Table values(1,'Komal',10);
insert into Stu_Table values(2,'Ajay',10);
insert into Stu_Table values(3,'Rakesh',10);
insert into Stu_Table values(4,'Bhanu',10);
insert into Stu_Table values(5,'Santosh',10);
insert into Stu_Table values(6,'Tanuj',10);


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


The SQL ALTER Syntax is used to modify the table and add a column name that you want to add and its data type.

ALTER TABLE table_name
ADD column_name column-definition


The given below Query alter a table 'Stu_Table' and add keyword add a column Stu_Class whose data type is varchar type.

Alter Table Stu_Table add Stu_Class varchar(10)

View data  Stu_Table

Stu_Id Stu_Name Stu_Class
1 Komal NULL
2 Ajay NULL
3 Rakesh NULL
4 Bhanu NULL
5 Santosh NULL
Share on Google+Share on Google+

SQL Alter Column

Posted on: December 20, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: SQL Alter Column   View All Comments

Post your Comment

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