在 MySQL 中创建子分区
我想在我的 MySQL 表上创建分区和子分区以优化表的性能。
例如:-
Create table mytest (id int not null, mydate date)
PARTITION BY LIST (id)
SUBPARTITION BY RANGE (TO_DAYS(mydate))
(
PARTITION P01 VALUES IN (1,2,5,6,8,10)
(
SUBPARTITION S01 VALUES LESS THAN ('2011-10-23'),
SUBPARTITION S02 VALUES LESS THAN ('2011-10-16'),
SUBPARTITION S03 VALUES LESS THAN ('2011-10-09')
));
就像这样,我尝试创建子分区,但收到错误,提示 RANGE 附近的语法不正确。
任何人都可以帮助我了解是否允许按列表分区和按范围子分区的信息。
I want to create a partitioning and subpartitioning on my MySQL table in order to optimize the performance of the table.
For Ex :-
Create table mytest (id int not null, mydate date)
PARTITION BY LIST (id)
SUBPARTITION BY RANGE (TO_DAYS(mydate))
(
PARTITION P01 VALUES IN (1,2,5,6,8,10)
(
SUBPARTITION S01 VALUES LESS THAN ('2011-10-23'),
SUBPARTITION S02 VALUES LESS THAN ('2011-10-16'),
SUBPARTITION S03 VALUES LESS THAN ('2011-10-09')
));
like this i m trying to create the subpartitioning but getting an error which says incorrect syntax near RANGE.
Can anyone help me with the info whether PARTITION BY LIST AND SUBPARTITION BY RANGE is allowed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能按
RANGE
进行子分区。您只能通过HASH
或KEY
进行子分区。 文档中说明:“在 MySQL 5.1 中,可以对按 RANGE 或 LIST 分区的表进行子分区。子分区可以使用 HASH 或 KEY 分区。”
You cannot subpartition by
RANGE
. You can only subpartition byHASH
orKEY
. It is stated in the documentation:"In MySQL 5.1, it is possible to subpartition tables that are partitioned by RANGE or LIST. Subpartitions may use either HASH or KEY partitioning."