0

I'm trying change the name of a column of my table, but it dont change the name, i have tried this command:

ALTER TABLE book_loan RENAME COLUMN idbook-loan TO idbook_loan;

1 Answers1

0

Do you need backticks around the column name with hyphens in it?

Also, you must repeat the data type of the column. Let's say it is INT ( you didn't mention it so that's a guess.

You want this.

ALTER TABLE book_loan RENAME COLUMN `idbook-loan` TO idbook_loan INT;

It's possible MySql doesn't recognize that hyphen-containing name as a schema object name without the backtick delimiters.

O. Jones
  • 103,626
  • 17
  • 118
  • 172