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
What is mysql connection limit?
Write a query to find duplicate rows in table?
How do I stop a mysql service?
Can mysql store files?
How to get current MySQL version?
What is tee command in mysql?
What is row level locking?
Why do we use pragma autonomous transaction?
How do I view a mysql database?
What is a storage engine? What are the differences between innodb and myisam engines?
How do I clear a mysql database?
what is cte? : Mysql dba
Does mysql case matter?
How do I set user privileges in mysql?
can you tell the order of sql select statement? : Mysql dba