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
I want to insert userid of a customer,order time,etc in a table called ordermaster with orderid as primary key.Same time the product codes and required quantities (a1,2 and a2 4 and so on)inserted in another table orderdetails with same orderid reference.How the code will be in JSP using MySQL?
How do you create a primary key?
What does mysql flush privileges do?
What are date and time data types in mysql?
Is foreign key indexed mysql?
How to display top 10 rows in mysql?
What are the types of queries?
How to update info already in a table and delete a row(s) from a table.
What is the difference between a database and a table?
What is view? How can you create and drop view in mysql?
What are the reasons for selecting lamp (linux, apache, mysql, php) instead of combination of other software programs, servers and operating systems?
Which command is used to view the content of the table in mysql?
Write a query to create a database and a table?
What is the maximum size of mysql database?
How will you export tables as an xml file in mysql?