ALLInterview.com :: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
   
 
Categories  >>  Software  >>  Databases  >>  MySQL
 
 


 

 
 Oracle interview questions  Oracle Interview Questions
 SQL Server interview questions  SQL Server Interview Questions
 MS Access interview questions  MS Access Interview Questions
 MySQL interview questions  MySQL Interview Questions
 Postgre interview questions  Postgre Interview Questions
 Sybase interview questions  Sybase Interview Questions
 DB Architecture interview questions  DB Architecture Interview Questions
 DB Administration interview questions  DB Administration Interview Questions
 DB Development interview questions  DB Development Interview Questions
 SQL PLSQL interview questions  SQL PLSQL Interview Questions
 Databases AllOther interview questions  Databases AllOther Interview Questions
Question
How can we change the name and data type of a column of a 
table?
 Question Submitted By :: Pranab
I also faced this Question!!     Rank Answer Posted By  
 
  Re: How can we change the name and data type of a column of a table?
Answer
# 1
To Change DataType of Column:
Sy: Alter Table <Table Name> Modify <ColumnName> <DataType>;
Ex: Alter Table Test Modify EmpId varchar(5);
 
Is This Answer Correct ?    62 Yes 12 No
M. Ravindar
 
  Re: How can we change the name and data type of a column of a table?
Answer
# 2
To Change Name of Column:
Sy: Alter Table <Table Name> Change <Old ColumnName> <New
ColumnName>;
Ex: Alter Table Test Change EmpId EID varchar(5);
 
Is This Answer Correct ?    17 Yes 19 No
M. Ravindar
 
 
 
  Re: How can we change the name and data type of a column of a table?
Answer
# 3
ALTER TABLE `<tablename>` CHANGE `<old column>` `<new
column>` new datatype( length )
 
Is This Answer Correct ?    5 Yes 15 No
Abhishek
 
  Re: How can we change the name and data type of a column of a table?
Answer
# 4
Hi This is yOgEsH....!!
By this query we can change the data type of particular column :

ALTER TABLE products ALTER COLUMN price TYPE numeric(10,2);
 
Is This Answer Correct ?    7 Yes 8 No
Yogesh Verma
 
  Re: How can we change the name and data type of a column of a table?
Answer
# 5
o Change DataType of Column:
Sy: Alter Table <Table Name> Modify <ColumnName> <DataType>;
Ex: Alter Table Test Modify EmpId varchar(5);
 
Is This Answer Correct ?    9 Yes 4 No
Ashish
 
  Re: How can we change the name and data type of a column of a table?
Answer
# 6
To change the name of the column:

ALTER TABLE TABLENAME RENAME COLUMN OLD_COLUMN_NAME TO
NEW_COLUMN_NAME;

eg: alter table employee rename column emp_name to ename;

To change the datatype of a column:

ALTER TABLE TABLENAME MODIGY COLUMN_NAME NEW_DATA_TYPE;

eg: alter table employee modify ename varchar(50);

NOTE: u cannot modify column of a datatype from larger value
to smaller value.U can do it only if there is no data in ur
column.

eg: alter table employ_detail modify emp_addr varchar(5);

ORA-01441: cannot decrease column length because some value
is too big

alter table employ_detail modify emp_id number(2)

ORA-01440: column to be modified must be empty to decrease
precision or scale
 
Is This Answer Correct ?    9 Yes 3 No
Nithya
 
  Re: How can we change the name and data type of a column of a table?
Answer
# 7
excuse mr pls
ALTER TABLE products ALTER COLUMN price TYPE numeric
(10,2);
uyah nanhi vhalta hai
 
Is This Answer Correct ?    3 Yes 3 No
Szsad
 
  Re: How can we change the name and data type of a column of a table?
Answer
# 8
to add new columns in databases


alter table <table name> add column <column name> datatype;
 
Is This Answer Correct ?    2 Yes 1 No
Aftab Alam
 

 
 
 
Other MySQL Interview Questions
 
  Question Asked @ Answers
 
What are the other commands to know the structure of table using MySQL commands except explain command? SigmaTree2
how to repair a table in mysql?  2
What is Inner Joints and Outer Joints ? What is right outer joints,left outer joints,right inner joints , left inner joints , HP2
How to see the database architecture in MySQL??  3
What is SERIAL data type in MySQL? Aspire3
What is diff b/w MYISAM and INNODB storage engine. and also define the benifits and drawbacks of both storage engine  1
How do you prevent MySQL from caching a query?  1
what is the querry for all managers salary?  2
What is maximum size of a database in MySQL? V2-Solutions13
What are the differences between MySQL_fetch_array(), MySQL_fetch_object(), MySQL_fetch_row()?  2
what is the main difference between myisam and innodb Wipro2
what is the difference between MyIsam and InnoDb engine?  2
 
For more MySQL Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2012  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com