目的
调查分区表是否支持sequence。即在分区表中,如果引用了sequence的话,是否能够保证每次insert新的record后,sequence自增。
结论
支持
测试环境
centos 7 2004, postgresql 12.4
实验过程
创建sequence
test=# create sequence myseq minvalue 0;
CREATE SEQUENCE
创建分区表
test=# create table parttab (w_id integer, seq_field integer default nextval('myseq'), info text) partition by hash (w_id);
CREATE TABLE
test=# \d parttab
Partitioned table "public.parttab"
Column | Type | Collation | Nullable | Default
-----------+---------+-----------+----------+----------------------------
w_id | integer | | |
seq_field | integer | | | nextval('myseq'::regclass)
info | text | | |
Partition key: HASH (w_id)
Number of partitions: 0
<