MYSQL (11) ---- create createtableuser (idint (11) partition by date, namevarchar (255), birthdaydatedefaultNULL, PRIMARYKEY (id, birthday) partitionbyrange (birthday) (partitionp0valueslessthan (198
MYSQL experience (11) ---- create table user (id int (11) not null AUTO_INCREMENT, name varchar (255), birthday date default NULL, primary key (id, birthday) partition by range (birthday) (partition p0 values less than ('100
MYSQL experiences (11)-partitioning tables by date
Create
Create table user (id int (11) not null AUTO_INCREMENT,
Name varchar (255 ),
Birthday date default NULL,
Primary key (id, birthday ))
Partition by range (birthday)
(Partition p0 values less than ('2017-12-26 '),
Partition p1 values less than ('2017-12-01 '));
Error
ERROR 1697 (HY000): VALUES value for partition 'p0 'must have type INT
Normal Creation
Create table user (id int (11) not null AUTO_INCREMENT,
Name varchar (255 ),
Birthday date default NULL,
Primary key (id, birthday) engine = innodb
Partition by range (to_days (birthday ))
(PARTITION p0 values less than (to_days ('2017-01-01 ')),
PARTITION p1 values less than (to_days ('2017-01-01 ')),
PARTITION p2 values less than (to_days ('2017-01-01 ')),
PARTITION p3 values less than (to_days ('2017-01-01 ')),
PARTITION p4 values less than (to_days ('2017-01-01 ')),
PARTITION p5 values less than (to_days ('2017-01-01 ')),
PARTITION p6 values less than maxvalue );
Execute interpretation Scan
Explain partitions select birthday from user where birthday> '2017-06-01 'and birthday <'2017-12-12' \ G
Output
* *************************** 1. row ***************************
Id: 1
Select_type: SIMPLE
Table: user
Partitions: p0, p4
Type: index
Possible_keys: NULL
Key: PRIMARY
Key_len: 7
Ref: NULL
Rows: 2
Extra: Using where; Using index
1 row in set (0.00 sec)