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
Consider you have the following three tables which have to be linked together.
What is max connections in mysql?
Is mysql free for commercial use?
What is the use of procedure in mysql?
what is the difference between gui testing and database testing? : Mysql dba
Write a command with which mysql table can be repaired
How does mysql clustering work?
Is mysql free for enterprise?
Can I use mariadb instead of mysql?
What is normalization and list the different types of normalization?
How show all tables in mysql query?
Is mysql a free database?
How can we get total number of records by query in mysql?
How to write after insert event update trigger on the same table in mysql?
Where is mysql password stored?