Results 1 to 5 of 5

 

Thread: Warning using reserved words in MySQL

  1. #1
    Home is where I hang my @

    Status
    Offline
    Join Date
    Sep 2003
    Location
    My Bedroom
    Posts
    412
    Thanks
    0
    Thanked 0 Times in 0 Posts


    Hi,

    After a fun packed morning of importing a database backup again, I have found that I had some reserved MySQL words as column names in my tables.

    Now you would have thought that PHPAdmin would not allow these in - nor would MySQL, but having such previously ok column names such as 'FROM' or 'OPTION' is not a good idea, as if you use the command:

    mysql -h**** -u***** -p***** db_name < my.dump

    to re-install backups like me, MySql does not like these names as column names.

    Thought I'd just share this knowledge.

    Daniel

  2. #2
    Registered User

    Status
    Offline
    Join Date
    Aug 2003
    Posts
    2,448
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah, always used to use desc for description columns and it caused all sorts of headaches. You need to surround them with ` (next to the 1 key) to get mysql to ignore them. My version of PhpMyAdmin does this for me so it sounds like your my.dump has been made with out these.

  3. #3
    Home is where I hang my @

    Status
    Offline
    Join Date
    Sep 2003
    Location
    My Bedroom
    Posts
    412
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Mate,

    Yeah, I normally do a straight:

    mysqldump -h <host name> -u<username> -p<password> <db name> > my-dump.file

    Is there a command I can add into the mysqldump command to add these ```'s?

    Dan

  4. #4
    Home is where I hang my @

    Status
    Offline
    Join Date
    Sep 2003
    Location
    My Bedroom
    Posts
    412
    Thanks
    0
    Thanked 0 Times in 0 Posts
    There is just so much I could learn about MySQL, I still haven't got around to learning everything about Oracle yet after 10yrs, and that's my job!

    Found this:

    --quote-names, -Q

    Quote database, table, and column names within '`' characters. If the server SQL mode includes the ANSI_QUOTES option, names are quoted within '"' characters. As of MySQL 4.1.1, --quote-names is on by default, but can be disabled with --skip-quote-names.

    And this:

    --allow-keywords

    Allow creation of column names that are keywords. This works by prefixing each column name with the table name.

    Dan
    Last edited by DanielCoe; 21-07-05 at 05:39 PM.

  5. #5
    toneharb's Avatar
    Registered User

    Status
    Offline
    Join Date
    Dec 2003
    Location
    Chippenham Wiltshire
    Posts
    442
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Loads of underscores in table names caused sql errors when importing . Learnt the hard way !

    Also spaces in field names - works fine for inserts updates deletes even backing up but restoring db - big problems .



Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Excel encasing words in " "
    By Wardy in forum Programming
    Replies: 8
    Last Post: 10-01-07, 04:41 PM
  2. Connect to MySql on a remote server?
    By accelerator in forum Programming
    Replies: 3
    Last Post: 07-01-05, 03:54 PM
  3. Anyone anygood with xml, php, mysql and Affiliate Window
    By AnnonnyMouse in forum Affiliate Marketing Lounge
    Replies: 1
    Last Post: 23-09-04, 11:00 AM
  4. MS Access & mySQL
    By Frostie in forum Programming
    Replies: 5
    Last Post: 04-10-03, 10:46 AM

Bookmarks

Posting Permissions

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

Content Relevant URLs by vBSEO 3.5.0 RC2