Home > Blockchain >  Renaming a column in MySQL
Renaming a column in MySQL

Time:11-24

ALTER TABLE departments
RENAME COLUMN department_name TO dept_name VARCHAR(50);

Why I am getting this errorenter image description here

CodePudding user response:

could be you need CHANGE

ALTER TABLE departments CHANGE department_name  dept_name VARCHAR(50); 

or only RENAME

 ALTER TABLE departments
 RENAME COLUMN department_name TO dept_name ;

CodePudding user response:

Oh hello, why don't you try this instead:

ALTER TABLE table CHANGE actualName newName

good luck have fun coding

CodePudding user response:

It depends on your version of MariaDB.

Try this query :

ALTER TABLE departments CHANGE COLUMN department_name dept_name VARCHAR(50);

Look here :

  • Related