2
여기에 게시하기 전에이 문제에 대한 검색을 수행했습니다.존재하는 참조가있는 경우에도 MySQL 외래 키 오류
mysql> insert into Buyer values (5594, CURDATE(), 490, 4830);
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`oppminer`.`buyer`, CONSTRAINT `FK3D9119337C53076` FOREIGN KEY (`office_id`) REFERENCES `Office` (`id`))
내가 참조 행이 존재 함을 확인했습니다 :
| Buyer | CREATE TABLE `Buyer` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`created` datetime DEFAULT NULL,
`office_id` bigint(20) DEFAULT NULL,
`primaryContact_id` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FK3D9119337C53076` (`office_id`),
KEY `FK3D911938ADC7080` (`primaryContact_id`),
CONSTRAINT `FK3D911938ADC7080` FOREIGN KEY (`primaryContact_id`) REFERENCES `Contact` (`id`),
CONSTRAINT `FK3D9119337C53076` FOREIGN KEY (`office_id`) REFERENCES `Office` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5595 DEFAULT CHARSET=latin1 |
+-------
| Office | CREATE TABLE `Office` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`agency_id` bigint(20) DEFAULT NULL,
`location_id` int(11) DEFAULT NULL,
`primaryContact_id` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FK8C9C2ADC3FBD3FD6` (`agency_id`),
KEY `FK8C9C2ADCFF56D2BF` (`location_id`),
KEY `FK8C9C2ADC8ADC7080` (`primaryContact_id`),
CONSTRAINT `FK8C9C2ADC8ADC7080` FOREIGN KEY (`primaryContact_id`) REFERENCES `Contact` (`id`),
CONSTRAINT `FK8C9C2ADC3FBD3FD6` FOREIGN KEY (`agency_id`) REFERENCES `Agency` (`id`),
CONSTRAINT `FK8C9C2ADCFF56D2BF` FOREIGN KEY (`location_id`) REFERENCES `Location` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=491 DEFAULT CHARSET=latin1 |
+--------
나는 또한 테이블 인덱스를 조사 : 여기
mysql> select * from Office where id = 490;
+-----+-----------+-----------+-------------+-------------------+
| id | name | agency_id | location_id | primaryContact_id |
+-----+-----------+-----------+-------------+-------------------+
| 490 | Top Level | 88 | 7363 | 451 |
+-----+-----------+-----------+-------------+-------------------+
1 row in set (0.00 sec)
은 테이블 설명입니다 여기 이 문제입니다 :
------------------------
LATEST FOREIGN KEY ERROR
------------------------
110503 12:32:12 Transaction:
TRANSACTION 17A89, ACTIVE 0 sec, OS thread id 4493770752 inserting
mysql tables in use 1, locked 1
1 lock struct(s), heap size 376, 0 row lock(s), undo log entries 1
MySQL thread id 17, query id 31610 localhost root update
insert into Buyer values (5594, CURDATE(), NULL, 4830)
Foreign key constraint fails for table `oppminer`.`buyer`:
CONSTRAINT `FK3D911938ADC7080` FOREIGN KEY (`primaryContact_id`) REFERENCES `Contact` (`id`)
Trying to add to index `FK3D911938ADC7080` tuple:
DATA TUPLE: 2 fields;
0: len 8; hex 80000000000012de; asc ;;
1: len 4; hex 800015da; asc ;;
But the parent table `oppminer`.`Contact`
or its .ibd file does not currently exist!
두 대의 기계에서 동일한 덤프를 복원했습니다. 작업 컴퓨터에서 문제가있는 컴퓨터에서 오류가 발생하는 명령을 성공적으로 수행 할 수 있습니다. 아이디어가 스택 오버플로입니까?
덤프는 마지막 외래 키 실패에'NULL'를 삽입하려고했던 말했다. –
실제로이 게시물을 삭제했다고 생각했지만,이 게시물에 걸려 넘어 질 수있는 사람에게는 MySQL 5.5.11 GA (Snow Leopard 용 GA)에 몇 가지 중요한 문제가있었습니다. 5.5.8로 다운 그레이드하면 이러한 문제가 해결되었습니다. –