postgresql - 如何在 PostgreSQL 中使用分区内分区(多级分区或分区分区)
问题描述
如何在 PostgreSQL 中的分区内使用分区我想在 PostgreSQL 中进行多级分区就像在第一个表中的列 id 和第二个分区表中的列日期一样,这将是三层层次结构
解决方案
本文通过示例 https://joaodlf.com/postgresql-10-partitions-of-partitions.html对此进行了很好的解释
CREATE TABLE dt_totals (
dt_total date NOT NULL,
geo varchar(2) not null,
impressions integer DEFAULT 0 NOT NULL,
sales integer DEFAULT 0 NOT NULL
)
PARTITION BY RANGE (dt_total);
CREATE TABLE dt_totals_201801
PARTITION OF dt_totals
FOR VALUES FROM ('2018-01-01') TO ('2018-01-31');
CREATE TABLE dt_totals_201801
PARTITION OF dt_totals
FOR VALUES FROM ('2018-01-01') TO ('2018-01-31')
PARTITION BY LIST (geo);
CREATE TABLE dt_totals_UK_201801 PARTITION OF dt_totals_201801 FOR VALUES IN ('UK');
CREATE TABLE dt_totals_US_201801 PARTITION OF dt_totals_201801 FOR VALUES IN ('US');
CREATE TABLE dt_totals_AU_201801 PARTITION OF dt_totals_201801 FOR VALUES IN ('AU');
推荐阅读
- javascript - 在javascript(香草或jQuery)中序列化表单数据时如何获得多个选择选项?
- python-3.x - 使用 python3 在 Windows 10 上安装 OpenCV 4
- javascript - JS:根据元素的 CSS 显示状态更改 innerHTML
- javascript - delegate-handle 和 getByHandle 是什么意思?
- python - 如何修复“没有名为'easysnmp'的模块”
- google-apps-script - 使用 Google Script 抓取网页,异步网站?
- ruby-on-rails - 查询包含所有项目的关联
- html - 为什么位置固定的标签在不同的html页面上的位置略有不同?
- javascript - 有什么办法可以强制浏览器不提示记住密码框吗?
- kubernetes - Cert-manager 在带有 webhook 的 kubernetes 上失败