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

What is a procedure example?

498


How do I run a query in mysql?

487


How much does mysql enterprise cost?

490


Is Mysql query is case sensitive?

528


What is a tinyint?

513






What is mysql in dbms?

489


What are the advantages and disadvantages of using mysql?

510


What is the difference between char and varchar in mysql?

508


What is data directory in mysql?

485


How to change a password for an existing user via mysqladmin?

569


What is default schema in mysql?

491


How do I create a schema in mysql?

475


what is mySQL. Is there any specific qualification required to do this course ? What is the scope in India after doing mySQL

953


What is difference between oracle sql and mysql?

497


What is row level locking in access?

488