【发布时间】:2015-05-07 18:56:23
【问题描述】:
由于约束错误,我正在对 INSERT... ON DUPLICATE KEY 语句进行故障排除,但我不可逆转地编辑了有问题的行,并且不再出现错误。我很确定我编辑了request_path 或target_path。某些区域已经存在的一些值:
store_id | id_path | is_system
6 | category/494 | 1
查询是
INSERT INTO `core_url_rewrite` (`store_id`,`category_id`,`product_id`,`id_path`,`request_path`,`target_path`,`is_system`)
VALUES (6, 494, NULL, 'category/494', 'lessons/teacher-s-planning-calendar/n-a', 'catalog/category/view/id/494', 1)
ON DUPLICATE KEY UPDATE
`store_id` = VALUES(`store_id`),
`category_id` = VALUES(`category_id`),
`product_id` = VALUES(`product_id`),
`id_path` = VALUES(`id_path`),
`request_path` = VALUES(`request_path`),
`target_path` = VALUES(`target_path`),
`is_system` = VALUES(`is_system`)
错误是
Integrity constraint violation: 1062 Duplicate entry 'category/494-1-6'
for key 'UNQ_CORE_URL_REWRITE_ID_PATH_IS_SYSTEM_STORE_ID'
此表上有两个唯一键。
UNIQUE KEY `UNQ_CORE_URL_REWRITE_REQUEST_PATH_STORE_ID` (`request_path`,`store_id`),
UNIQUE KEY `UNQ_CORE_URL_REWRITE_ID_PATH_IS_SYSTEM_STORE_ID` (`id_path`,`is_system`,`store_id`)
手动更改行上的某些值后,我不再收到此约束错误。什么会导致我的查询提示该约束错误?
【问题讨论】:
标签: mysql constraints unique-constraint