MYSQL user experience (11)-Table Partitioning by date

Source: Internet
Author: User
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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.