Menu

#2927 (ok 3.2.3) Adding foreign key when table name contains a dot

3.2.2
fixed
1
2013-06-11
2009-09-27
M. Buecher
No

When trying to add a foreign key to a table field and if the table names contain a dot, then the generated SQL command is wrong.

DB: nfltlgl
Tables: nfl.seasontypes; nfl.season
Wanted foreign key for `nfl.season`.`type` is `nfl.seasontypes`.`type`

phpmyadmin:
ALTER TABLE `nfl.season` ADD FOREIGN KEY ( `type` ) REFERENCES `nfltlgl`.`nfl` ( `seasontypes` );

correct:
ALTER TABLE `nfl.season` ADD FOREIGN KEY ( `type` ) REFERENCES `nfl.seasontypes`(`type`);

So phpmyadmin somehow splits the table name instead of using it completely.
Workaorund is too use "nfl_" as a prefix and avoid dots in table names.

Discussion

  • Marc Delisle

    Marc Delisle - 2009-09-29

    Hmmm, I was sure that dots were not allowed in table names, but they are since MySQL 5.1.6:
    http://dev.mysql.com/doc/refman/5.1/en/identifiers.html
    But phpMyAdmin does not support these, yet.

     
  • Marc Delisle

    Marc Delisle - 2009-10-17
    • assigned_to: nobody --> lem9
     
  • Marc Delisle

    Marc Delisle - 2009-10-17
    • summary: Adding foreign key not working (weird sql command) --> Adding foreign key when table name contains a dot
     
  • Marc Delisle

    Marc Delisle - 2009-10-17

    Fixed in subversion, thanks for reporting.

     
  • Marc Delisle

    Marc Delisle - 2009-10-17
    • priority: 5 --> 1
    • summary: Adding foreign key when table name contains a dot --> (ok 3.2.3) Adding foreign key when table name contains a dot
    • status: open --> open-fixed
     
  • Marc Delisle

    Marc Delisle - 2009-10-30
    • status: open-fixed --> closed-fixed
     
  • Michal Čihař

    Michal Čihař - 2013-06-11
    • Status: closed-fixed --> fixed
     
MongoDB Logo MongoDB