向表catalog\u produt\u flat\u 8-magento 1.9添加外键时出现问题
当我尝试重新索引时
Product Flat Data index process unknown error:
exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1022 Can't write; duplicate key in table '#sql-4c36_d67'
我尝试添加mysql
ALTER TABLE catalog_product_flat_8
ADD CONSTRAINT FK_CAT_PRD_FLAT_8_ENTT_ID_CAT_PRD_ENTT_ENTT_ID FOREIGN KEY (entity_id) REFERENCES catalog_product_entity (entity_id) ON DELETE CASCADE ON UPDATE CASCADE;
仍然
1022 Can't write; duplicate key in table '#sql-4c36_1099
我在网上登记信息
SELECT * FROM information_schema.REFERENTIAL_CONSTRAINTS WHERE CONSTRAINT_SCHEMA = "magento_db" AND CONSTRAINT_NAME LIKE "FK_CAT_PRD_FLAT_8_ENTT_ID_CAT_PRD_ENTT_ENTT_ID"
但是没有记录
select COLUMN_NAME, CONSTRAINT_NAME, REFERENCED_COLUMN_NAME,
REFERENCED_TABLE_NAME
from information_schema.KEY_COLUMN_USAGE
where TABLE_NAME = 'catalog_product_flat_8';
我只有实体id的主密钥
所以,我查一下:
select *
from information_schema.table_constraints
where constraint_schema = 'magento_db'
只有一条实体id为“flat\u 8”的记录(主),
我在information\u schema的每个表中搜索“fk\u cat\u prd\u flat\u 8\u entt\u id\u cat\u prd\u entt\u entt\u id”
结果:
`information_schema`.`INNODB_SYS_FOREIGN`
| ID |FOR_NAME |REF_NAME | N_COLS | TYPE |
| magento_db/FK_CAT_PRD_FLAT_8_ENTT_ID_CAT_PRD_ENTT_E... |magento_db/#sql-6756_19e0f | magento_db/catalog_product_entity | 1 | 5 |
`information_schema`.`INNODB_SYS_FOREIGN_COLS`
| ID | FOR_COL_NAME| REF_COL_NAME | POS |
| magento_db/FK_CAT_PRD_FLAT_8_ENTT_ID_CAT_PRD_ENTT_E... | entity_id | entity_id | 0 |
我不知道,请帮忙
1条答案
按热度按时间uujelgoq1#
我现在也有同样的问题。键在innodb\u sys\u foreign\u cols中,但在表\u约束中缺少。由于这个原因,显然不能通过改变表来删除键。
我提出的唯一解决方案是转储、删除和导入数据库。