I need to split a MySQL table among temporary data (the field starts in the following table).
CREATE TABLE `table1` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`fk_id` bigint(20) NOT NULL,
`begin` bigint(20) NOT NULL,
PRIMARY KEY (`id`),
KEY `FK1E57078DB20EC268` (`fk_id`)
) ENGINE=MyISAM AUTO_INCREMENT=10443288 DEFAULT CHARSET=latin1
When I try to break as follows:
alter table table1 partition by range (begin) (
PARTITION until_2010_07 VALUES LESS THAN (1280620800000),
PARTITION 2010_08 VALUES LESS THAN (1283299200000),
PARTITION 2010_09 VALUES LESS THAN (1285891200000),
PARTITION 2010_10 VALUES LESS THAN (1288569600000),
PARTITION 2010_11 VALUES LESS THAN (1291161600000),
PARTITION 2010_12 VALUES LESS THAN (1293840000000),
PARTITION from_2011 VALUES LESS THAN MAXVALUE
);
I get a MySQL error: ERROR 1503 (HY000): A PRIMARY KEY must include all columns in the table partitioning function
As I understand from the mysql document, the partition column should belong to the primary key. The problem for me is that I want to change PRIMARY_KEY as compound, i.e. PRIMARY KEY ('id','fk_id','begin')without changing existing identifier columns (because this is the field used in the application to generate bookmarks, so renumbering identifiers is not an option)
How can I change PRIMARY_KEY so that I can perform partitioning?
source
share