postgresql10以前版本的分区表是通过继承追加制约实现的,postgresql10新追加PARTITION BY可以直接定义list和range分区,检证如下:
postgres=# CREATE TABLE test(id integer,name text) PARTITION BY LIST (id);
postgres=# CREATE TABLE test_p1 PARTITION OF test FOR VALUES IN (10);
postgres=# CREATE TABLE test_p20 PARTITION OF test FOR VALUES IN (20);
postgres=# \d+ test;
Table “public.test”
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------±--------±----------±---------±--------±---------±-------------±------------
id | integer | | | | plain | |
name | text | | | | extended | |
Partition key: LIST (id)
Partitions: test_p1 FOR VALUES IN (10),
test_p20 FOR VALUES IN (20)
postgres=# \d+ test_p1;
Table “public.test_p1”
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------±--------±----------±---------±