- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to rename a column in an existing MySQL table?
To rename a column in an existing MySQL table we can use ALTER TABLE command with CHANGE keyword as follows −
mysql> Alter table Student CHANGE Email Emailid Varchar(30); Query OK, 5 rows affected (0.38 sec) Records: 5 Duplicates: 0 Warnings: 0
With the help of query above, MySQL has changed the name of column ‘Email’ to ‘Emailid’.
We can specify the same data type & size or different data type & size with new column name as follows −
mysql> Alter table Student CHANGE Emailid Mailid char(35); Query OK, 5 rows affected (0.29 sec) Records: 5 Duplicates: 0 Warnings: 0
With the help of query above, MySQL has changed the name of the column from ‘Emailid’ to ‘Mailid’ along with its data type from varchar(30) to char(35).
- How can we RENAME an existing MySQL event?
- Adding new enum column to an existing MySQL table?
- How can I drop an existing column from a MySQL table?
- Rename a table in MySQL using RENAME TABLE command
- How to rename a table in MySQL?
- How to add column to an existing table in PostgreSQL?
- How to add columns to an existing MySQL table?
- How to SELECT * and rename a column in MySQL?
- How can we apply a NOT NULL constraint to a column of an existing MySQL table?
- Inserting data into a new column of an already existing table in MySQL?
- How can I change the name of an existing column from a MySQL table?
- Create MySQL query to create a table from an existing table?
- Rename column name in MySQL?
- How to add a new column to an existing table using JDBC API?
- How can we put comments in a column of existing MySQL table?