Databases| SQL| MySQL| Questions? | Software Development
 

MySQL Add Column

                         

MySQL Add Column is used to add the column to the existing table. The Alter table keyword is used to modify the table structure and add  keyword is used to add the new column  in a table.

Understand with Example

The Tutorial describe Add Column in MySQL. To understand the example we use select query that returns the set of columns records from table employee.

 

 

 

 

Query

 

 select * from employee;

 

Output

 

+----+------------------------+----------------------+--------+
| id | name                   | designation          | salary |
+----+------------------------+----------------------+--------+
| 1  | Mr.sandeep kumar suman | programmer           | 6000   |
| 2  | Miss.anusmita          | programmer           | 6000   |
| 3  | Mr.ravi kant           | software developer   | 10000  |
| 4  | Mr.suman saurabh       | sr. graphic designer | 17000  |
| 5  | Mr.rakesh              | graphic designer     | 12000  |
| 6  | Mr.noor                | content writer       | 13500  |
| 7  | Mr.girish tewari       | programmer           | 5000   |
| 8  | Mr.komal choudhary     | programmer           | 5000   |
| 9  | Miss.hardeep           | technical writer     | 5000   |
| 10 | Mr.deepak mohanty      | editor               | 15000  |
| 11 | Mr.vinod kumar         | software developer   | 8500   |
| 12 | Mr.vikash              | content writer       | 8500   |
| 13 | Mr.amit raghuvanshi    | programmer           | 6000   |
| 14 | Mr.vineet bansal       | programmer           | 6000   |
| 15 | Mr.amardeep patel      | programmer           | 8000   |
| 16 | Mr.santosh kashyap     | graphic designer     | 7500   |
| 17 | Mr.govind              | technical writer     | 6000   |
| 18 | Mr.vimlaksha gautam    | technical writer     | 15000  |
+----+------------------------+----------------------+--------+

 

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

Query

 

ALTER TABLE employee ADD address VARCHAR(50);

 

Output

 

+----+------------------------+----------------------+--------+---------+
| id | name                   | designation          | salary | address |
+----+------------------------+----------------------+--------+---------+
| 1  | Mr.sandeep kumar suman | programmer           | 6000   |         |
| 2  | Miss.anusmita          | programmer           | 6000   |         |
| 3  | Mr.ravi kant           | software developer   | 10000  |         |
| 4  | Mr.suman saurabh       | sr. graphic designer | 17000  |         |
| 5  | Mr.rakesh              | graphic designer     | 12000  |         |
| 6  | Mr.noor                | content writer       | 13500  |         |
| 7  | Mr.girish tewari       | programmer           | 5000   |         |
| 8  | Mr.komal choudhary     | programmer           | 5000   |         |
| 9  | Miss.hardeep           | technical writer     | 5000   |         |
| 10 | Mr.deepak mohanty      | editor               | 15000  |         |
| 11 | Mr.vinod kumar         | software developer   | 8500   |         |
| 12 | Mr.vikash              | content writer       | 8500   |         |
| 13 | Mr.amit raghuvanshi    | programmer           | 6000   |         |
| 14 | Mr.vineet bansal       | programmer           | 6000   |         |
| 15 | Mr.amardeep patel      | programmer           | 8000   |         |
| 16 | Mr.saurabh             | technical writer     | 5000   |         |
| 17 | Mr.santosh kashyap     | graphic designer     | 7500   |         |
| 18 | Mr.govind              | technical writer     | 6000   |         |
| 19 | Mr.vimlaksha gautam    | technical writer     | 15000  |         |
+----+------------------------+----------------------+--------+---------+

 

                         

» View all related tutorials
Related Tags: php sql mysql c query table delete io sed tab if condition ie record where records to base ci e

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
 
Tell A Friend
Your Friend Name

 

 
Recently Viewed
Software Solutions
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.