MySQL partition table

Source: Internet
Author: User

Mysql> CREATE TABLE stu (Id int (9) NOT NULL auto_increment, Name varchar (+) NOT null default ' ', Time datetime default Null,primary key (Id,time)) partition by range (To_days (time)) (partition P0 values less than (to_days (' 2015-03-21 ')), Partition P1 values less than (to_days (' 2015-03-22 ')); Query OK, 0 rows affectedmysql> Show create TABLE stu;+-------+---------------------------------------------------- --------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------+| Table | Create Table                               &NBS P                          ,         &NB Sp                          ,         &N Bsp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                                               |+-------+---------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------+| Stu   | CREATE TABLE ' Stu ' (  ' Id ' int (9) NOT null auto_increment,  ' Name ' varchar (+) NOT null DEFAULT ',  ' time ' DateTime not NULL default ' 0000-00-00 00:00:00 ',  PRIMARY KEY (' Id ', ' time ')) Engine=innodb default charset=utf8/*!5 0100 PARTITION by RANGE (To_days (Time)) (PARTITION p0 values less THAN (736043) ENGINE = innodb, partition P1 values L ESS THAN (736044) ENGINE = InnoDB) */|+-------+--------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- ----------------------+1 row in setmysql> ALTER TABLE STU Add partition (partition P2 values less than (To_days (' 2015-3 -23 ')); Query OK, 0 rows affectedrecords:0  duplicates:0  Warnings:0mysql> Show CREATE table stu;+-------+-------- --------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------+| Table | Create Table                     &NBSP                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                                 &NBSp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp       |+-------+---------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- ---------------------+| Stu   | CREATE TABLE ' Stu ' (  ' Id ' int (9) NOT null auto_increment,  ' Name ' varchar (+) NOT null DEFAULT ',  ' time ' DateTime NOT NULL Default ' 0000-00-00 00:00:00 ',  PRIMARY KEY (' Id ', ' time ')) Engine=innodb default charset=utf8/*!50100 Partiti On by RANGE (To_days (Time)) (PARTITION p0 values less THAN (736043) ENGINE = innodb, partition P1 values less THAN (73 6044) engine = innodb, partition P2 VALUES less THAN (736045) engine = InnoDB) */|+-------+------------------------- --------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------+1 Row in Set

MySQL partition table

Related Article

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.