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

What are the reasons for selecting lamp (linux, apache, mysql, php) instead of combination of other software programs, servers and operating systems?

548


What are the different data types in mysql?

457


What command is used to delete the data from the table without deleting the table structure?

431


How do I install mysql on windows 7?

457


What is deterministic in mysql?

483






Can we rename database in mysql?

474


Can we store pdf files in mysql?

447


What is a result set object?

508


What is dblink?

467


What is int mysql?

495


What are the advantages/disadvantages of mysql and php?

483


How do you name a table?

473


What is the use of mysql workbench?

492


How do you kill a long running query in mysql?

450


How many sql ddl commands are supported by 'mysql'?

564