Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rename table with spaces mysql

Tags:

mysql

I have a table 'A B C' (with spaces, don't ask me why) in MySQL database. I have to rename it to 'ABC' This query doesn't work :(

rename table 'A B C' to 'ABC'

What should be the correct query?

I get the same usual error

'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version'
like image 705
Ank Avatar asked Dec 27 '22 05:12

Ank


2 Answers

Escape the name with backticks.

rename table `A B C` to ABC
like image 111
Joe Stefanelli Avatar answered Jan 15 '23 00:01

Joe Stefanelli


Use backticks:

rename table `A B C` to ABC;
like image 45
Ike Walker Avatar answered Jan 15 '23 00:01

Ike Walker