I added a foreign key contstraint to a table (I was getting Error 150, so I added an index to the column and after that I was able to add the FK).
Then I added a new record to the table, no problems so far. However, when I got back to edit the table, I noticed that all FK contstraints were gone. Any idea why?
Thank you
foreign keys disappear
1. DDL for table accounts2 that was just created, saved, but the edit tab in VS is still on:
CREATE TABLE cms.accounts2 (
account_id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
accounttype_id INT(11) UNSIGNED,
opendate DATE,
INDEX indexaccounttype_id (accounttype_id),
PRIMARY KEY (account_id),
CONSTRAINT FKaccounttype_id FOREIGN KEY (accounttype_id)
REFERENCES accounttypes(accounttype_id)
)
TYPE=InnoDB
2. DDL for the same table after I closed the tab and reopened it (right click-> Edit Table):
CREATE TABLE cms.accounts2 (
account_id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE,
accounttype_id INT(11) UNSIGNED,
opendate DATE,
INDEX indexaccounttype_id (accounttype_id),
PRIMARY KEY (account_id)
)
TYPE=InnoDB
AUTO_INCREMENT=1
3. DDL for the second table
CREATE TABLE cms.accounttypes (
accounttype_id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE,
accounttype VARCHAR(20) NOT NULL,
PRIMARY KEY (accounttype_id)
)
TYPE=InnoDB
AUTO_INCREMENT=5
4. mysql version is: 4.0.12
5. As I mentioned earlier, SHOW CREATE TABLE reflects the foreign key in it.
Thank you.
CREATE TABLE cms.accounts2 (
account_id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
accounttype_id INT(11) UNSIGNED,
opendate DATE,
INDEX indexaccounttype_id (accounttype_id),
PRIMARY KEY (account_id),
CONSTRAINT FKaccounttype_id FOREIGN KEY (accounttype_id)
REFERENCES accounttypes(accounttype_id)
)
TYPE=InnoDB
2. DDL for the same table after I closed the tab and reopened it (right click-> Edit Table):
CREATE TABLE cms.accounts2 (
account_id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE,
accounttype_id INT(11) UNSIGNED,
opendate DATE,
INDEX indexaccounttype_id (accounttype_id),
PRIMARY KEY (account_id)
)
TYPE=InnoDB
AUTO_INCREMENT=1
3. DDL for the second table
CREATE TABLE cms.accounttypes (
accounttype_id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE,
accounttype VARCHAR(20) NOT NULL,
PRIMARY KEY (accounttype_id)
)
TYPE=InnoDB
AUTO_INCREMENT=5
4. mysql version is: 4.0.12
5. As I mentioned earlier, SHOW CREATE TABLE reflects the foreign key in it.
Thank you.