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

Answers were Sorted based on User's Feedback



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

Answer / m. ravindar

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 ?    63 Yes 12 No

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

Answer / ashish

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 ?    10 Yes 4 No

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

Answer / guru

You can change the column data type using this query:

Alter table table_name modify column_name datatype(length)

For example:
Alter table user modify name char(30)
You can change column name using this query:

Alter table table_name change old_column_name
new_column_name datatype(length)

For example:
Alter table user change user user_name char(30)

If you want to change column name and data type in single
query, then you use this query:

Alter table table_name change old_column_name
new_column_name new_datatype(10)

For example:
Alter table user change name user_name char(30)

For more details visit,

http://www.phponwebsites.com/2013/12/mysql-change-column-name.html
(for change column name)

http://www.phponwebsites.com/2013/12/mysql-change-column-datatype.html(for
change column datatype)

Is This Answer Correct ?    6 Yes 0 No

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

Answer / 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

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

Answer / aftab alam

to add new columns in databases


alter table <table name> add column <column name> datatype;

Is This Answer Correct ?    2 Yes 1 No

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

Answer / szsad

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

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

Answer / yogesh verma

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

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

Answer / m. ravindar

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

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

Answer / abhishek

ALTER TABLE `<tablename>` CHANGE `<old column>` `<new
column>` new datatype( length )

Is This Answer Correct ?    5 Yes 15 No

Post New Answer

More MySQL Interview Questions

In which format data is stored in mysql database?

0 Answers  


What is latest version of mysql?

0 Answers  


How do I start mysql database?

0 Answers  


How to print message in mysql trigger?

0 Answers  


List some mysql advantages and disadvantages?

0 Answers  






I have a table like this tblData (month int,Qty int) and i am inserting three rows in this table 1.tblData Values (1,100) 2.tblData Values (2,200) 3.tblData Values (3,300) The Result I want is the Running total of the field Qty that is 1 100 100 2 200 300 3 300 600 What is the Query for that ?

4 Answers  


What is a join? Explain the different types of mysql joins.

1 Answers  


How do you flush privileges?

0 Answers  


How to change the database engine in mysql?

0 Answers  


What is a tinyint?

0 Answers  


How can we know the number of days between two given dates using MySQL?

2 Answers   Base2 Infotech, Webworks,


What is database migration in mysql?

0 Answers  


Categories