Ishan Sharma Ishan Sharma - 1 year ago 74
SQL Question

mysql: Not able to create a table

create table 5390e910_abb3_40e2_bdfa_bd9d369e6dc6 like sample_table

is failing.

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 '5390e910_abb3_40e2_bdfa_bd9d369e6dc6 like
notification_sample_history' at line 1

Now I don't see any flaw with the above name as the mysql documentation says:

  1. 64 characters max

  2. can start with any alphabet/digit

  3. an contain underscores/alphabets/digits

Though I am able to run something like this:

create table 1f8b784f_f580_4a82_9e93_167a2d9c79f5 like sample_table

Answer Source

I believe it's the first "e". When I swap that character for any other letter, the query works just fine.

I'm not positive on this, but my suspicion is that MySQL is reading your string and considering it to mean the number "5,390 times 10 to the power of 910abb3[etc]". And while all-numeric table names are valid they must be quoted.

Try enclosing your table name in back-ticks. This works for me:

create table `5390e910_abb3_40e2_bdfa_bd9d369e6dc6` like abbreviations;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download