无法在 mysql 上对表进行分区

SWa*_*ahi 1 mysql foreign-keys database-partitioning

当我alter table在 innodb 表上运行分区时,我在 Mysql 5.7 上收到此错误:

Foreign keys are not yet supported in conjunction with partitioning
Run Code Online (Sandbox Code Playgroud)

知道我已经drop foreign key有了这张表,以及drop foreign key这张表的 id 在哪里。

现在这是我的表架构:

| record | CREATE TABLE `record` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `altitude` smallint(6) DEFAULT NULL,
  `counter` double DEFAULT NULL,
  `datetime` datetime NOT NULL,
  `details` longtext,
  `deviation` smallint(6) DEFAULT NULL,
  `engine` tinyint(1) DEFAULT NULL,
  `event` smallint(6) DEFAULT NULL,
  `fuel_level` double DEFAULT NULL,
  `gsm_level` int(11) DEFAULT NULL,
  `latitude` double NOT NULL,
  `longitude` double NOT NULL,
  `satellite` smallint(6) DEFAULT NULL,
  `speed` smallint(6) DEFAULT NULL,
  `time` time NOT NULL,
  `treated` tinyint(1) NOT NULL DEFAULT '0',
  `id_driver` bigint(20) DEFAULT NULL,
  `id_vehicle_device` bigint(20) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `FK_ai9y9d52lx1xvtaiv3w0x60a5` (`id_driver`),
  KEY `FK_ilwlg0mt87bxyemx4tov1elni` (`id_vehicle_device`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
Run Code Online (Sandbox Code Playgroud)

Luk*_*zda 5

来自分区的限制和限制

分区 InnoDB 表不支持外键。使用InnoDB存储引擎的分区表不支持外键。更具体地说,这意味着以下两个陈述是正确的:

  • 使用用户定义分区的 InnoDB 表的定义不能包含外键引用;定义包含外键引用的 InnoDB 表不能被分区。

  • InnoDB 表定义不能包含对用户分区表的外键引用;具有用户定义分区的 InnoDB 表不能包含外键引用的列。