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

Why I am getting this errorenter image description here

ScaisEdge
  • 131,976
  • 10
  • 91
  • 107
shayde
  • 1
  • `RENAME COLUMN` must be used for to rename the column **only**. You cannot specify the datatype there, even when it is not changed. – Akina Nov 23 '21 at 10:40
  • On the screenshot the source of error is missed space between the name of the table and `RENAME` keyword. This causes the `departmentsRENAME` to be distinguished as the table name, and `COLUMN` keyword is distinguished as incorrect ALTER TABLE command. I.e. a typo. – Akina Nov 23 '21 at 10:42

3 Answers3

1

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

ALTER TABLE table CHANGE actualName newName

good luck have fun coding

0

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 ;
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107
0

It depends on your version of MariaDB.

Try this query :

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

Look here :

CecileV
  • 16
  • 2