4

I've imported a csv into MySQL. PHPMyAdmin helpfully created a table called TABLE 8 (with a space).

When I try to rename in SQL:

RENAME TABLE 8 to gender

I get the error:

#1064 - 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 '`TABLE 8` to `gender`' at line 1

I have tried back-ticks, quotes... seemingly everything...

I guess it's the space that's causing the problem but I'm out of ideas.

Mureinik
  • 297,002
  • 52
  • 306
  • 350
stilts77
  • 191
  • 3
  • 14

1 Answers1

6

The syntax is wrong, you're missing the table keyword (and yes, note the `s to escape the table name containing a space):

RENAME TABLE `TABLE 8` TO gender

Alternatively, you could use the fuller syntax:

ALTER TABLE `TABLE 8` RENAME TO gender
Mureinik
  • 297,002
  • 52
  • 306
  • 350