Haven
Haven

Reputation: 45

MySQL Syntax error - table name

I'm running into a strange problem with mysql does not like my table name.

mysql> DROP TABLE IF EXISTS 6e0OU1QgkU7Pj6ycQF0U_results;
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 '6e0OU1QgkU7Pj6ycQF0U_results' at line 1

mysql> DROP TABLE IF EXISTS 6epGz4xKzfKd6A9e1ASP_results;
Query OK, 0 rows affected (0.00 sec)

mysql>

Any idea why the first query has a syntax error while the second query is allowed?

Upvotes: 0

Views: 580

Answers (2)

Abhik Chakraborty
Abhik Chakraborty

Reputation: 44844

Thats because mysql does not recognize the table name since it starts with a digit MeN

Identifiers may begin with a digit but unless quoted may not consist solely of digits.

https://dev.mysql.com/doc/refman/5.0/en/identifiers.html

It is recommended that you do not use names that begin with Me or MeN, where M and N are integers. For example, avoid using 1e as an identifier, because an expression such as 1e+3 is ambiguous. Depending on context, it might be interpreted as the expression 1e + 3 or as the number 1e+3.

You can try as

DROP TABLE IF EXISTS `6e0OU1QgkU7Pj6ycQF0U_results`;

Upvotes: 2

Damian Yerrick
Damian Yerrick

Reputation: 4664

It's probably the 6e0, which the SQL parser thinks is a number in scientific notation: 6 * 100.

Upvotes: 5

Related Questions