All pastes #427015 Raw Edit

snoyes

public sql v1 · immutable
·published 2007-04-06 15:25 UTC
rendered paste body
mysql> CREATE TABLE test (id int default null, index(id), foreign key (id) references test(id)) ENGINE=InnoDB;Query OK, 0 rows affected (0.06 sec)mysql> INSERT INTO test VALUES (1);ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`test/test`, CONSTRAINT `test_ibfk_1` FOREIGN KEY (`id`) REFERENCES `test` (`id`))mysql> INSERT INTO test VALUES (null);Query OK, 1 row affected (0.03 sec)mysql> UPDATE test SET id = 1;ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`test/test`, CONSTRAINT `test_ibfk_1` FOREIGN KEY (`id`) REFERENCES `test` (`id`))