Tu *_*ran 6 mysql partitioning foreign-keys alter-table
我的表格结构如下:
CREATE TABLE `child_table` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`value` int,
`ref_id` int,
PRIMARY KEY (`id`),
KEY `ref_id` (`ref_id`),
CONSTRAINT `FK4E9BF08E940F8C98` FOREIGN KEY (`ref_id`) REFERENCES `parent_table` (`id`) ON DELETE CASCADE
)
Run Code Online (Sandbox Code Playgroud)
运行语句以添加分区时,它会失败并显示错误:
ERROR 1217: Cannot delete or update a parent row: a foreign key constraint fails
SQL Statement:
ALTER TABLE `learning`.`child_table` PARTITION BY HASH(ref_id) PARTITIONS 10
Run Code Online (Sandbox Code Playgroud)
所以我用parent_table删除外部约束,然后再次运行.它仍然失败并显示相同的错误.
我做错了什么吗?
| 归档时间: |
|
| 查看次数: |
4414 次 |
| 最近记录: |