![]() ![]() ![]() I vaguely remember that this was also the case when adding foreign keys, but this bug seems to have been fixed since: select |Īlter table t2 add constraint abc foreign key (t1_id) references t1 (id) ĮRROR 1452 (23000): Cannot add or update a child row:Ī foreign key constraint fails ("test". Once you open a new connection, the option defaults to the global value. Set foreign_key_checks = 1 - does not validate foreign keys Changing a session variable like foreignkeychecks last only for the duration of the session. Insert into t2 (id, t1_id) values (2,2) - invalid With MySQL you can use ON DELETE SET NULL on the foreign key. I created my MySQL database using phpMyAdmin 3.5.8.1deb1 in Ubuntu. It will then refrain from using new Version 8 features when it generates SQL for you. Cant create FOREIGN KEY CONSTRAINT in MySQL. ![]() Edit / Preferences / Modeling / MySQL / set the Default Target MySQL Version' to 5.5.60. Note that set foreign_key_checks = 1 does not validate foreign keys, so if someone manages to add invalid values whilst foreign keys are disables, you end up with an inconsistent db: insert into t1 (id) values (1) MySQL Workbench allows you to set the MySQL target version it uses when generating a schema. Try temporary disabling foreign keys (make sure no ones allowed to update the db meanwhile): create table t1 (id int not null primary key) engine = innodb Ĭreate table t2 (id int not null primary keyĪlter table t1 change column id id int auto_increment ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |