Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Oct 2007
    Posts
    91
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Is there anything wrong with my create table statement?

    Hi guys,
    I have an sql query which mysql is giving error:
    Code:
    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:
    Code:
    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.

    Regards,
    Ramki

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    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.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,550
    Thanks
    78
    Thanked 4,382 Times in 4,347 Posts
    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.
    Code:
    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?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •