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

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why do you think it is advised to not to use guid and character columns as clustered index arrays?

888


write a query to mysql in safe mode and to change the root password

741


How to decrement dates by 1 in mysql?

739


What can you do with mysql?

688


Is mysql workbench a dbms?

757


How do I connect to mysql database?

710


Is mysql port 3306 tcp or udp?

695


suppose data is copie to oracle to sql by using DTS. Actully it taken 2 hours. suppose some day distribute the server in the middle of 2 hours. after how can i get the data ?

1912


What is the difference between truncate and delete in mysql?

808


Does mysql scale well?

674


What is mysql enterprise edition?

668


Why we use mysql workbench?

662


When to use order by in delete statement?

789


How to create a test table in your mysql server?

725


How many mysql connections can handle?

664