This is a migrated thread and some comments may be shown as answers.

MySql Foreign key not working with tables containing dot (.)

1 Answer 48 Views
Databases and Data Types
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Erik
Top achievements
Rank 2
Erik asked on 11 Mar 2011, 06:01 PM
Hello,

I have 2 tables, test 1 and test2 in MySql.
Table test2 has a field LinkedTest1 that points to table test1, with a foreign key

When i try this, no problem in ORM.

Now, let's change test1 to testers.test1... oops... no foreign keys are created...

What to do now...

CREATE TABLE `testers.test1` (
  `idtest1` int(11) NOT NULL AUTO_INCREMENT,
  `bla` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`idtest1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1$$

CREATE TABLE `test2` (
  `idtest2` int(11) NOT NULL AUTO_INCREMENT,
  `Boe` varchar(45) DEFAULT NULL,
  `LinkedTest1` int(11) DEFAULT NULL,
  PRIMARY KEY (`idtest2`),
  KEY `fkLinkedTest1` (`LinkedTest1`),
  CONSTRAINT `fk_test2_LinkedTest1` FOREIGN KEY (`LinkedTest1`) REFERENCES `testers.test1` (`idtest1`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1$$

1 Answer, 1 is accepted

Sort by
0
Ady
Telerik team
answered on 17 Mar 2011, 11:47 AM
Hi Proovit,

 Is 'testers' the same database as the 'test2' table? OpenAccess does not support referencing a table from another database, for MySql. In case both the tables are in the same database, please specify the table name as follows - `testers`.`test1` instead of - `testers.test1`.

Do get back in case you need further assisstance.

Kind regards,
Ady
the Telerik team
Tags
Databases and Data Types
Asked by
Erik
Top achievements
Rank 2
Answers by
Ady
Telerik team
Share this question
or