View Full Version : Is there anything wrong with my create table statement?

10-04-2011, 10:50 AM
Hi guys,
I have an sql query which mysql is giving error:

CREATE TABLE '42011-10-04 08:10:37'(`id` INT NOT NULL AUTO_INCREMENT,PRIMARY KEY(`id`),`url_string` VARCHAR(100),`loadtime` float(10),`comment` VARCHAR(160),`urlflag` INT NOT NULL DEFAULT '0')

Is there anything wrong with query, its giving the error as below:

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 ''
42011-10-04 08:10:37'(`id` INT NOT NULL AUTO_INCREMENT,PRIMARY KEY(`id`),`url_'
at line 1

Please help.


10-04-2011, 02:39 PM
Yes there is, you can't name your table the way you have. perhaps you can save us time in this forum and get right to the point of why you think you need to name your tables in that manner.

Old Pedant
10-05-2011, 12:58 AM
Actually, *IF* you are using MySQL, you *can* name a table like that, if you do it right.

You must use BACK TICKS around that table name, *NOT* apostrophes.

The ` back tick usually shares the key with the ~ tilde.

CREATE TABLE `42011-10-04 08:10:37` ( .... );

Having said that...

I'm with GuelphDad. What earthly reason would there be for doing something like this?