MySQL adds one partition per month and queries all partitions

Source: Internet
Author: User
Create PROCEDURE usp_partition () begindeclare _time datetime;declare num int;declare _p VARCHAR (DEFAULT p;declare p1 VA) Rchar (20);/* Gets the first day of the next one months */select Date_add (Curdate ()-day (Curdate ()) +1,interval 1 month) as _time;/* remove the '-' in the time */select REPLACE (_time, '-', ') as Num; SELECT _p+num as P1; SET concat (' ALTER TABLE BOOK8 ADD PARTITION (PARTITION p ', p1, ' VALUES less THAN (to_days (' "', Yearweek (p1), '))); END

Querying all partitions

Select Partition_name part, Partition_expression expr, partition_description descr, table_rows from Informatio N_schema.partitions WHERE Table_schema = Schema () and table_name= ' Book9 ';

MySQL adds one partition per month and queries all partitions

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.