Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How can we change the name and data type of a column of a
table?

Answer Posted / nithya

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 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I create a stored procedure in mysql?

835


Can varchar be primary key?

876


How do I set user privileges in mysql?

834


How to shutdown mysql server?

1003


How to get a list of columns in an existing table?

830


How do I start mysql server?

837


Is blocked because of many connection errors unblock with mysqladmin flush hosts?

867


How can I create database in mysql?

868


How do you name a table?

829


What is schema in mysql?

849


What is row level locking in mysql?

929


Is mysql case-sensitive?

834


How do I find my mysql username and password?

915


Why does mysql have so many connections?

842


How triggers can be used in mysql?

950