forums › forums › SQLyog › Using SQLyog › Can't create foreign keys
- This topic is empty.
-
AuthorPosts
-
-
December 17, 2004 at 4:21 pm #8708glenn351Member
I have 2 tables defiined as follows:
Members:
CENMSSN char (9) Primary
CENCODE char (1)
CENLAST char (15)
CENFIRST char (15) ……
Dependents:
CDEMSSN char(9) Primary
CDECODE char(1) Primary
CDELAST char (15)
CDEFIRST char (15)…….
I'm trying to create the relationship between CENMSSN and CDEMSSN. I have InnoDB set on both files and have indexes on both as well. SQLYog refuses to create the relationship. What am I missing?
-
December 17, 2004 at 4:49 pm #16721RiteshMember
Are you using SQLyog 4.0?
-
December 17, 2004 at 4:56 pm #16722glenn351Member
Yes, in fact I just upgraded this AM.
-
December 17, 2004 at 6:14 pm #16723RiteshMember
Can you cut-n-paste the Create table… statement for both the tables?
-
December 17, 2004 at 6:23 pm #16724glenn351Member
The tables weren't created in SQLyog, they were ODBC imports.
However, here's the statement from when I tried to create the relationship and it failed.
/*[1:17:15 PM][ 551 ms]*/ alter table `ufa`.`u01_caspdepn` add foreign key (CDEMSSN) references `u01_caspenrl` (CENMSSN)
And just so you know that they are InnoDB, here's from the Database info screen.
u01_caspdepn InnoDB 9 Fixed
u01_caspenrl InnoDB 9 Fixed
-
December 17, 2004 at 6:37 pm #16725RiteshMember
To get a CREATE TABLE… statement for a table just select the table in the object browser and the corresponding statement is shown in the Objects… tab.
Anyway, I have fowarded the issue to my development team.
-
December 17, 2004 at 6:57 pm #16726glenn351Member
Ok, here you go
/*DDL Information For – ufa.u01_caspdepn*/
Table Create Table
u01_caspdepn CREATE TABLE `u01_caspdepn` (
`CDEMSSN` char(9) NOT NULL default '',
`CDECODE` char(1) NOT NULL default '',
`CDECODE2` char(3) NOT NULL default '',
`CDESSN` char(9) NOT NULL default '',
`CDELAST` char(18) NOT NULL default '',
`CDEFIRST` char(12) NOT NULL default '',
`CDESEX` char(1) NOT NULL default '',
`CDEEFF` char(8) NOT NULL default '',
`CDEDROP` char(8) NOT NULL default '',
`CDEDOB` char(8) NOT NULL default '',
`CDECERT` char(8) NOT NULL default '',
`CDERSENT` char(8) NOT NULL default '',
`CDERCERT` char(8) NOT NULL default '',
`CDEDOM` char(8) NOT NULL default '',
`CDEDOD` char(8) NOT NULL default '',
`CDEDIVRC` char(8) NOT NULL default '',
`CDEDBLDT` char(8) NOT NULL default '',
`CDEDBL` char(1) NOT NULL default '',
`CDESCHOL` char(8) NOT NULL default '',
`CDESTAT` char(1) NOT NULL default '',
`CDECOB` char(10) NOT NULL default '',
`CDEPAID` char(1) NOT NULL default '',
`CDEOVR19` char(1) NOT NULL default '',
`CDEFLAG1` char(1) NOT NULL default '',
`CDEFLAG2` char(1) NOT NULL default '',
`CDETCODE` char(1) NOT NULL default '',
`CDECRDT` char(8) NOT NULL default '',
`CDECSTAT` char(2) NOT NULL default '',
`CDEFIL50` char(9) NOT NULL default '',
`CDEOPER` char(3) NOT NULL default '',
`CDECHGDT` char(8) NOT NULL default '',
`CDECHGTM` char(4) NOT NULL default '',
PRIMARY KEY (`CDEMSSN`,`CDECODE`),
KEY `CDEMSSN` (`CDEMSSN`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*DDL Information For – ufa.u01_caspenrl*/
Table Create Table
u01_caspenrl CREATE TABLE `u01_caspenrl` (
`CENMSSN` char(9) NOT NULL default '',
-
December 17, 2004 at 6:58 pm #16727RiteshMember
Oops – looks like u01_caspenrl didnt get through 🙂
-
December 18, 2004 at 8:03 am #16728RiteshMember
We are running 4.1.7.
We created two tables – dependents and members to reproduce the error. The create table statements are:
Code:CREATE TABLE `dependents` ( Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
       `CDEMSSN` char(9) NOT NULL default '',                                                                                                                                                                                 Â
       `CDECODE` char(1) NOT NULL default '',                                                                                                                                                                                 Â
       `CDELAST` char(15) default NULL,                                                                                                                                                                                    Â
       `CDEFIRST` char(15) default NULL,                                                                                                                                                                                   Â
       PRIMARY KEY  (`CDEMSSN`,`CDECODE`),                                                                                                                                                                                  Â
       KEY `CDEMSSN` (`CDEMSSN`),                                                                                                                                                                                       Â
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8;and
Code:CREATE TABLE `members` ( Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
     `CENMSSN` char(9) NOT NULL default '',                                                                                                 Â
     `CENCODE` char(1) default NULL,                                                                                                    Â
     `CENLAST` char(15) default NULL,                                                                                                    Â
     `CENFIRST` char(15) default NULL,                                                                                                   Â
     PRIMARY KEY  (`CENMSSN`)                                                                                                        Â
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ÂWe then created the required FK. The SQL for FK creation as generated by SQLyog is:
Code:alter table `manitest`.`dependents` add foreign key (CDEMSSN) references `members` (CENMSSN) on update no action;The whole process went smoothly without any problems and we were able to create the FK.
Did we miss something?
-
-
AuthorPosts
- You must be logged in to reply to this topic.