Maintenance of Table partitioning

Source: Internet
Author: User

-----------Table Partition maintenance------------------increase partition ALTER TABLE name add PARTITION partition name values less THAN (value)----DELETE partition ALTER TABLE name drop PARTITION Partition Table name

----TRUNCATE partition deletes the current partition's data, but he does not delete the current partition, nor does it affect the other partitions ALTER TABLE name TRUNCATE PARTITION existing partition table---Merge partition High Line cannot be merged into the low boundary of the ALTER TABLE table name M Erge partitions partition 1, partition 2 into PARTITION partition table 2

CREATE TABLE dlist ( dt_date  date not NULL) PARTITION by RANGE (dt_date) (     PARTITION P1 values less THAN (to_date (' 1/1/2009 ', ' dd/mm/yy '),      PARTITION p2 VALUES less THAN (to_date (' 1/ 1/2011 ', ' dd/mm/yy '),      PARTITION P4 VALUES less THAN (MAXVALUE)    );  ---Delete partition  alter TABLE dlist drop PARTITION P4;  ---Add Table partition  alter table dlist add PARTITION P5 VALUES less THAN (to_date (' 1/1/2012 ', ' dd/mm/yy ')); --Inserting data insert INTO Dlist VALUES (to_date (' 1/1/2009 ', ' dd/mm/yy ')); INSERT into Dlist VALUES (to_date (' 6/6/2009 ', ' dd/mm/yy ')); INSERT into Dlist VALUES (to_date (' 1/12/2009 ', ' dd/mm/yy ')); INSERT into Dlist VALUES (to_date (' 1/1/2010 ', ' dd/mm/yy ')); INSERT into Dlist VALUES (to_date (' 1/6/2010 ', ' dd/mm/yy ')); INSERT into Dlist VALUES (to_date (' 1/1/2011 ', ' dd/mm/yy ')); INSERT into Dlist VALUES (to_date (' 1/12/2011 ', ' dd/mm/yy '));

SELECT *from dlist; Select*from dlist PARTITION (p1); Select*from dlist PARTITION (p2); Select*from dlist PARTITION (p5); ---intercept partition ALTER TABLE dlist TRUNCATE PARTITION (p2); --Merge partition ALTER TABLE dlist merge partitions p2,p5 into PARTITION P5;

Maintenance of Table partitioning

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.