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
How do I restart mysql on windows?
How do I change the max connections in mysql?
How do I disconnect mysql workbench?
What is blob and clob?
How to get the number of rows selected or affected by a sql statement?
What is the difference between sql and mysql and oracle?
What is difference between mysqli and pdo?
What is the current mysql version?
How do I change global variables in mysql?
What are the different tables present in MySQL?
What sql does mysql use?
can you elaborate on blob and text in mysql? : Mysql dba
How many triggers are possible in mysql?
What is a user defined variable?
How do I free up space in mysql?