我有一个像这样的表结构:

CREATE TABLE `cdr` (`id` bigint(20) NOT NULL AUTO_INCREMENT,
                    `dataPacketDownLink` bigint(20) DEFAULT NULL,
                    `dataPacketUpLink` bigint(20) DEFAULT NULL,
                    `dataPlanEndTime` datetime DEFAULT NULL,
                    `dataPlanStartTime` datetime DEFAULT NULL,
                    `dataVolumeDownLink` bigint(20) DEFAULT NULL,
                    `dataVolumeUpLink` bigint(20) DEFAULT NULL,
                    `dataplan` varchar(255) DEFAULT NULL,
                    `dataplanType` varchar(255) DEFAULT NULL,
                    `createdOn` datetime DEFAULT NULL,
                    `deviceName` varchar(500) DEFAULT NULL,
                    `duration` int(11) NOT NULL,
                    `effectiveDuration` int(11) NOT NULL,
                    `hour` int(11) DEFAULT NULL,
                    `eventDate` datetime DEFAULT NULL,
                    `msisdn` bigint(20) DEFAULT NULL,
                    `quarter` int(11) DEFAULT NULL,
                    `validDays` int(11) DEFAULT NULL,
                    `dataLeft` bigint(20) DEFAULT NULL,
                    `completedOn` datetime DEFAULT NULL,
                PRIMARY KEY (`id`),
                KEY `msisdn_index` (`msisdn`),
                KEY `eventdate_index` (`eventDate`)
            ) ENGINE=MyISAM AUTO_INCREMENT=55925171 DEFAULT CHARSET=latin1

当我创建分区时-
ALTER TABLE cdr PARTITION BY RANGE (TO_DAYS(eventdate))  (
    PARTITION p01 VALUES LESS THAN (TO_DAYS('2013-09-01')),
    PARTITION p02 VALUES LESS THAN (TO_DAYS('2013-09-15')),
    PARTITION p03 VALUES LESS THAN (TO_DAYS('2013-09-30')),
    PARTITION p04 VALUES LESS THAN (MAXVALUE));

得到
error 1503: A primary key must include all columns in the table's partitioning function

我到处都读到了这个,但是什么也没得到,所以请让我知道如何对这张表进行分区。我有20+百万条记录。

谢谢你。

最佳答案

我已经通过添加带有主键的eventdate解决了这个问题。

关于mysql - 收到错误1503 : A primary key must include all columns in the table's partitioning function,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20260043/

10-13 00:17