Home Sql Sql-functions MySQL Add Column

Related Tutorials


 
 

Share on Google+Share on Google+

MySQL Add Column

Advertisement
MySQL Add Column tutorial explains you to add the column to the existing table. The table structure can be changed using 'Alter table' query.

MySQL Add Column

     

MySQL Add Column tutorial explains you to add the column to the existing table. The table structure can be changed using 'Alter table' query. You can now add the new column  in a table using add  keyword in the query.

Understand with Example

The Tutorial describes Add Column in MySQL. To understand the example, lets see all the columns and its values from table employee using select query.

 

 

 

 

Query
 select * from employee;
Output

 

+----+--------+----------------------+
| id | name   | designation          |
+----+--------+----------------------+
| 1  | Ajay   | programmer           |
| 2  | Vinay  | programmer           |
| 4  | Kamal  | sr. graphic designer |
| 5  | Rajiv  | graphic designer     |
| 6  | Nitin  | content writer       |
| 7  | Sachin | programmer           |
| 8  | Karan  | programmer           |
+----+--------+----------------------+

The Alter Table employee is used to modify the table 'employee' and add a new column 'address' to the existing table 'employee'.

ALTER TABLE employee ADD address VARCHAR(50);

Now you can see the changed table and its value by select query.

Query
 select * from employee;
Output

 

+----+--------+----------------------+--------+
| id | name   | designation          |address |
+----+--------+----------------------+--------+
| 1  | Ajay   | programmer           |        |
| 2  | Vinay  | programmer           |        |
| 4  | Kamal  | sr. graphic designer |        |
| 5  | Rajiv  | graphic designer     |        |
| 6  | Nitin  | content writer       |        |
| 7  | Sachin | programmer           |        |
| 8  | Karan  | programmer           |        |
+----+--------+----------------------+--------+
Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  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.

Posted on: October 6, 2010

Related Tutorials

Discuss: MySQL Add Column  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com