- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What can another keyword be used instead of MODIFY to modify the column/s of MySQL table?
We can use keyword CHANGE to modify the column/s of an existing table. With CHANGE keyword we can change the name of the column and its definition both. Its syntax would be a bit different from the syntax of ALTER TABLE with MODIFY keyword.
Syntax
Alter table table_name CHANGE old_columnname1 new_columnname1 datatype, CHANGE old_columnname2 new_columnname2 datatype… CHANGE old_columnnameN new_columnname datatype);
Example
In the example below, with the help of CHANGE keyword in ALTER Command, the name and size of the columns ‘City’ and ‘RollNo’ have been modified.
mysql> Alter table Student CHANGE Rollno Id int, CHANGE City Place Varchar(10); Query OK, 5 rows affected (0.40 sec) Records: 5 Duplicates: 0 Warnings: 0
But, if we only want to resize the column with CHANGE keyword then write old column name both the times after keyword CHANGE along with new size. The description is given in the example below
mysql> Alter table Student CHANGE Email Email Varchar(30); Query OK, 5 rows affected (0.33 sec) Records: 5 Duplicates: 0 Warnings: 0
- Related Articles
- How can we modify column/s of MySQL table?
- How to modify the size of column in MySQL table?
- How can I modify an existing column's data type?
- How to modify column default value in MySQL?
- How do I modify a MySQL column to allow NULL?
- How can we modify an existing MySQL event?
- How MySQL CONCAT() function, applied to the column/s of a table, can be combined with the column/s of other tables?
- How can we modify the definition of a MySQL view without dropping it?
- Can a number be used to name a MySQL table column?
- Modify an array based on another array JavaScript
- How can I modify an existing MySQL column’s data type?
- How can we create a new MySQL table by selecting specific column/s from another existing table?
- MongoDB query to update field and modify the data currently in column
- What are the different unit values that can be used with MySQL INTERVAL keyword?
- How can we apply BIT_LENGTH() function on the column/s of MySQL table?

Advertisements