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 can we get the number of rows affected by query?
What do we use to remove duplicate records while fetching a data in mysql ?
Is blocked because of many connection errors mysql?
How to decrement dates by 1 in mysql?
What is difference between pdo and mysqli?
In how many ways we can retrieve the data in the result set of MySQL using PHP? What is the difference between mysql_fetch_object and mysql_fetch_array ?
how you will show all records not containing the name "sonia" and the phone number '9876543210' order by the phone_number field.
What is offset limit?
How to create a table?
How many rows we can insert in a mysql table?
What is unsigned in mysql?
Can you tell the reasons for selecting lamp(linux, apache, mysql, php) instead of any other combination of software programs, servers, and operating system?
What are the advantages/disadvantages of mysql and php?
What is the difference between sql and mysql and oracle?
How do I delete a row in mysql?