gpt4 book ai didi

MySQL 分区错误

转载 作者:行者123 更新时间:2023-11-29 12:08:19 25 4
gpt4 key购买 nike

我正在运行 MySQL 5.6 并有下表:

CREATE TABLE `rawdata` (
`RawDataSeq` int(10) unsigned NOT NULL AUTO_INCREMENT,
`SpeciesSeq` int(10) unsigned DEFAULT NULL,
`DataSourceSeq` int(10) unsigned DEFAULT NULL,
`MeasurementSeq` int(10) unsigned DEFAULT NULL,
`RecordingDateTime` datetime DEFAULT NULL,
`RawSensorData` varchar(100) DEFAULT NULL,
`RawDataNumeric` decimal(36,18) DEFAULT NULL,
`RawDataString` varchar(100) DEFAULT NULL,
`RawDataDate` datetime DEFAULT NULL,
`RawDataTime` varchar(45) DEFAULT NULL,
`RawDataDateTime` datetime DEFAULT NULL,
`ActiveRecord` int(10) unsigned DEFAULT NULL,
`LastUpdateDate` datetime DEFAULT NULL,
`UserId` varchar(6) DEFAULT NULL,
`BadData` varchar(200) DEFAULT NULL,
PRIMARY KEY (`RawDataSeq`)
) ENGINE=MyISAM AUTO_INCREMENT=5676258 DEFAULT CHARSET=latin1

我尝试使用以下命令按“RecordingDateTime”对表进行分区:

ALTER TABLE rawdata PARTITION BY RANGE (RecordingDateTime) (
PARTITION p0 VALUES LESS THAN (2013),
PARTITION p1 VALUES LESS THAN (2014),
PARTITION p2 VALUES LESS THAN (2015),
PARTITION p3 VALUES LESS THAN (UNIX_TIMESTAMP('2015-06-01 00:00:00')),
PARTITION p4 VALUES LESS THAN MAXVALUE
);

我收到以下错误消息:

查询:ALTER TABLE rawdata PARTITION BY RANGE (RecordingDateTime) ( PARTITION p0 VALUES LESS THAN (2013), PARTITION p1 VALUES LESS THAN...错误代码:1659字段“RecordingDateTime”属于此类分区不允许的类型

非常感谢任何帮助。

最佳答案

更改为

PRIMARY KEY (`RawDataSeq`, RecordingDateTime)

ALTER TABLE rawdata PARTITION BY RANGE (TO_DAYS(RecordingDateTime)) (
PARTITION p_old VALUES LESS THAN (TO_DAYS('2013-01-01')),
PARTITION p2013 VALUES LESS THAN (TO_DAYS('2014-01-01')),
PARTITION p2014 VALUES LESS THAN (TO_DAYS('2015-01-01')),
PARTITION p2015 VALUES LESS THAN (TO_DAYS('2016-01-01')),
PARTITION future VALUES LESS THAN MAXVALUE
);

每年 12 月您需要的代码可以找到 here .

关于MySQL 分区错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31107129/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com