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                      
tip   SiteMap shows list of All Categories in this site.
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
 
Explain the difference between mysql and mysqli interfaces in PHP? TCS10
how to find 2nd highest salary in random database salary of employer.....  3
How can we change the name of a column of a table?  7
What is ACID?  2
Can anyone help me to create a good mysql database schema with an example. Thanks, Sekar.jr  1
A company wants to store their invoices in a database. They already have their customers and articles in that database. Both customer and article are each identified by an unique integer value. Please create the SQL statements for creating the necessary table(s) for storing the invoices in a MySQL database. An invoice should hold information like invoice number, customer, date, article(s) and quantity etc.  1
how many ways we can get the current date in mysql?  2
Explain multi-version concurrency control in MySQL?  2
what programming language which is used for testing and developement in sql?  3
please give me the answer for this: query which generates the second highest integer in the table?  8
date funciton  2
What is the difference Delete and Drop ?  6
 
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