I've exported a database from Access to a MySQL server (local)
While doing this it did not export the foreign keys I had assigned in the database with them. While inconvenient I thought it didn't matter since I could add them manually. However when I use the following command:
alter table betalingsstatus
add foreign key (bedrijf_id)
references bedrijven(bedrijf_id)
It says it successfully did add the constraint. However when I insert something into the table and I add a number that isn't in the table bedrijven it still inserts it. I had the same problem with other foreign keys I have in the database.
Put ENGINE=INNODB; after the creation - altering of those tables that you want to enforce the foreign key constraints.
Example:
CREATE TABLE mytbl
(
id int PRIMARY KEY AUTO_INCREMENT,
name varchar(10) NOT NULL
) ENGINE=INNODB;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.