PostgreSQL PARTITION Partition Table

Source: Internet
Author: User
Tags postgresql

PostgreSQL partition table, the operability is quite convenient.

However, you can only decide whether to partition the table at creation time, and decide on the partition criteria field, after the normal table is created, you cannot modify the partition table.

Note: Other methods can also be converted to a partitioned table.

As with other databases, partitioned tables serve as a DB feature, with the advantages of not having to say, physically dispersed, and logically unified.

One drawback that must be noted is that the partition table does not allow other tables to be referenced as foreign keys . Only in the real scene business logic as a foreign key, design times talk scene and then scrutiny.

At the same time, only each partition table can be indexed separately before PG 11, and no primary key, index, etc. can be established on the master table.

Pg 11 can be indexed later for the logical partition table (master table), and the partition sub-table is created automatically.

Simple sql:

1 --DROP TABLE dbo.table01;2 3 CREATE TABLEdbo.table01 (4ID bigserial not NULL,5Cre_timetimestampwithout time zone,6Notevarchar( -)7) PARTITION byRANGE (cre_time)8    with (9OIDS=FALSETen   ); One  A CREATE TABLEdbo.table01_2018 -PARTITION ofdbo.table01 -    for VALUES  from('2018-01-01 00:00:00') to('2019-01-01 00:00:00'); the  - CREATE TABLEdbo.table01_2017 -PARTITION ofdbo.table01 -    for VALUES  from('2017-01-01 00:00:00') to('2018-01-01 00:00:00'); +  - ALTER TABLEdbo.table01 +OWNER toPostgres

PostgreSQL PARTITION 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.