0

I am having such a hard time changing the column name. I KNOW my syntax is right yet I am getting an error message.

I am using this syntax:

    ALTER TABLE Customers RENAME COLUMN CustomerID TO CollaboratorID;

I keep getting this error message, ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'COLUMN CustomerID TO CollaboratorID' at line 2

PLEASE HELP.

  • It may be a version issue. Using dbfiddle.uk, the it works MySQL 8 but not 5.6 for example https://dbfiddle.uk/?rdbms=mysql_5.6&fiddle=7b12290f66805e660eee0fb2de9ac52e – SOS Mar 27 '22 at 23:35
  • Does this answer your question? [Rename a column in MySQL](https://stackoverflow.com/questions/30290880/rename-a-column-in-mysql) – SOS Mar 27 '22 at 23:45
  • Consider using Google search for example mysql 8.0 column rename tutorial OR mysql 5.7 column rename tutorial for more specific advice. – Wilson Hauck Mar 28 '22 at 01:14

1 Answers1

1

What does SELECT VERSION() report? The syntax you show was not supported until MySQL 8.0. Refer to the ALTER TABLE documentation and make sure to select the version of the product you use.

If you use an older version, you can rename a column this way:

ALTER TABLE Customers CHANGE COLUMN CustomerID CollaboratorId ...

But with this syntax you must repeat all parts of the column definition, including the data type, NOT NULL, DEFAULT, etc.

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
  • I am going to school at SNHU and we are using codio and they are using server version 5.5? I will try this! thank you!! – Kelly Witcher Mar 28 '22 at 01:43