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 are the reasons for selecting lamp (linux, apache, mysql, php) instead of combination of other software programs, servers and operating systems?
What are the different data types in mysql?
What command is used to delete the data from the table without deleting the table structure?
How do I install mysql on windows 7?
What is deterministic in mysql?
Can we rename database in mysql?
Can we store pdf files in mysql?
What is a result set object?
What is dblink?
What is int mysql?
What are the advantages/disadvantages of mysql and php?
How do you name a table?
What is the use of mysql workbench?
How do you kill a long running query in mysql?
How many sql ddl commands are supported by 'mysql'?