作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Partition BY RANGE是否不能应用于主键自增的表?我问它是因为看到一些( 1 , 2 )没有主键定义的创建表语句的例子。而且我的创建表语句给我错误:
A PRIMARY KEY must include all columns in the table's partitioning function
这是我的声明
CREATE TABLE `tbl_point` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`cord_x` double DEFAULT NULL,
`cord_y` double DEFAULT NULL,
`angle` int DEFAULT NULL,
PRIMARY KEY (`id`)
)
PARTITION BY RANGE (angle) (
PARTITION p0 VALUES LESS THAN (91),
PARTITION p1 VALUES LESS THAN (181),
PARTITION p2 VALUES LESS THAN (271),
PARTITION p3 VALUES LESS THAN (361)
)
还有一个问题:angle 列可以是 double 类型吗?因为当我将它设置为 double 时出现了这个错误:
The PARTITION function returns the wrong type
谢谢。
最佳答案
第一条错误信息相当明确:
A PRIMARY KEY must include all columns in the table's partitioning function
您必须按主键进行分区,或者在主键中包含 angle
我想你不想要后者,所以前者是解决方案。
关于第二个错误:
The PARTITION function returns the wrong type
的确,分区函数(这里的“angle
”就是所谓的“函数”,可以把它看成恒等函数)必须返回一个整数,如in the manual所述:
A partitioning key must be either an integer column or an expression that resolves to an integer.
关于MySQL Partition BY RANGE 不适用于主键?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13235221/
我是一名优秀的程序员,十分优秀!