版权声明:如若转载,请联系作者。 https://blog.csdn.net/liu16659/article/details/83513902
Mysql报错:ERROR 1697 (HY000): VALUES value for partition 'p0' must have type INT
1.报错原因
执行如下SQL语句时,出现
mysql> create table student
-> ( id int ,
-> name varchar(20),
-> address varchar(20),
-> score int,
-> birthday datetime
-> )
-> partition by range (birthday)(
-> partition p0 values less than ('1980-01-01') ENGINE = InnoDB,
-> partition p1 values less than ('1990-01-01') ENGINE = InnoDB,
-> partition p2 values less than ('2000-01-01') ENGINE = InnoDB
-> );
ERROR 1697 (HY000): VALUES value for partition 'p0' must have type INT
2.报错原因
将partition by range (birthday)
修改成partition by range COLUMNS(birthday)
即可。但是为什么这里添加column
就可以解决问题呢?
create table student
( id int ,
name varchar(20),
address varchar(20),
score int,
birthday datetime
)
partition by range COLUMNS(birthday)(
partition p0 values less than ('1980-01-01') ENGINE = InnoDB,
partition p1 values less than ('1990-01-01') ENGINE = InnoDB,
partition p2 values less than ('2000-01-01') ENGINE = InnoDB
);