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
Where is the mysql data directory?
Can mysql scale horizontally?
how you will Create a database on the mysql server with unix shell.
Is mysql free for commercial use?
What are the applications required to support mysql?
How do I stop a mysql service?
What are date and time data types in mysql?
How show all tables in mysql query?
What's new in mysql 8?
How many rows can be inserted in mysql at a time?
How would you get the current date in mysql?
How many tables we can create in mysql database?
What is the use of mysqli_query?
How many concurrent queries can mysql handle?
What is the difference between now() and current_date()?