Once CHECK CONSTRAINTS are enabled, I am sure there will be a way to turn
them off temporarily. Right now, you can create tables that have them but
they are not enforced. To quote
http://dev.mysql.com/doc/refman/5.0/en/create-table.html
InnoDB tables support checking of foreign key cons
Easier than that (though Sheeri's way would work):
ALTER TABLE yourtablename DISABLE KEYS;
SET FOREIGN_KEY_CHECKS=0;
... do your processing ...
SET FOREIGN_KEY_CHECKS=1;
ALTER TABLE yourtablename ENABLE KEYS;
http://dev.mysql.com/doc/refman/5.0/en/alter-table.html
http://dev.mysql.com/doc/refman/
Drop the keys and references, change it, and then re-create the keys
and references.
http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html
(a SHOW CREATE TABLE will show you the constraints including foreign
keys -- copy those, so you can create them later. Then you can use
Hello,
I need to turn off all constraints in a table (especially primary and
foreign keys) - because for example I need to exchange primary key
values of two rows in a table. And because of primary key constraints I
can do it directly. I would to turn off the constraint, rename value of
PK1 to