例如,数据:
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错误。
您的代码有几个问题,如阅读the documentation for MySQL LIST
Partitioning时所见:
LIST
仅允许使用整数值,不允许使用字符串
没有包罗万象的PARTITION BY LIST
选项:必须使用NOT IN
语法定义每个分区,这意味着您需要列出所有可能的值。