MySQL errorno 121
Check that all your constraints are really spelled out correctly, also check that there’s not any other tables that uses the constraint names FK_userId or FK_blogId
Check that all your constraints are really spelled out correctly, also check that there’s not any other tables that uses the constraint names FK_userId or FK_blogId
When creating a foreign key constraint, MySQL requires a usable index on both the referencing table and also on the referenced table. The index on the referencing table is created automatically if one doesn’t exist, but the one on the referenced table needs to be created manually (Source). Yours appears to be missing. Test case: … Read more
You should make car_id a primary key in cars.
table1.field1 has no index defined on it. It is required to place a FOREIGN KEY constraint on field1. With this: CREATE TABLE IF NOT EXISTS `testdb`.`table1` ( `id` INT UNSIGNED NOT NULL , `field1` VARCHAR(50) NULL , KEY ix_table1_field1 (field1), PRIMARY KEY (`id`) ) ENGINE = InnoDB; Everything should then work as expected.
You have two constraints called company.cid_FK. Rename one.
Error Code: 1005 — there is a wrong primary key reference in your code Usually it’s due to a referenced foreign key field that does not exist. It might be you have a typo mistake, or check case it should be same, or there’s a field-type mismatch. Foreign key-linked fields must match definitions exactly. Some … Read more