MySQL如何对不确定值的列表进行分区?

问题描述 投票:0回答:1

例如,数据:

id  fruits
1   apple
2   banana
3   uncertain_1
4   uncertain_2

我现在想对水果列进行分区

Alter Table fruits_table 
PARTITION BY list (fruits) 
(
PARTITION p_apple VALUES IN ('apple'),
PARTITION p_banana VALUES IN ('banana'),
PARTITION p_other VALUES NOT IN ('apple','banana')
);

但是看起来SQL会出现synax错误。

mysql partition
1个回答
0
投票

您的代码有几个问题,如阅读the documentation for MySQL LIST Partitioning时所见:

  1. LIST仅允许使用整数值,不允许使用字符串

  2. 没有包罗万象的PARTITION BY LIST选项:必须使用NOT IN语法定义每个分区,这意味着您需要列出所有可能的值。

© www.soinside.com 2019 - 2024. All rights reserved.