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
Is mysql case-sensitive?
What can I do with mysql?
Are stored procedures precompiled?
Where is the mysql config file?
What is mysql sleep process?
Explain the different types of constraints?
What is mysql root?
How to display nth highest salary from a table in a mysql query?
What are the critical issues you have resolved in your company
Is mysql a good database?
List the different types of normalization?
Explain Access Control Lists.
How do I create a schema in mysql?
How do I copy a table in mysql?
What is a tinyint in mysql?