Con*_*bil 4 postgresql metadata partitioning data-dictionary
如果我创建一个表和这样的分区......
CREATE TABLE tab1 (a int, b int) PARTITION BY RANGE(a);
CREATE TABLE tab1_p1 PARTITION OF tab1 FOR VALUES FROM (0) TO (100);
CREATE TABLE tab1_p2 PARTITION OF tab1 FOR VALUES FROM (100) TO (200);
Run Code Online (Sandbox Code Playgroud)
我如何随后检查范围?我试过浏览 information_schema.tables 和 information_schema.table_constraints 但到目前为止没有运气。
你需要研究一下pg_class
。您可以使用pg_get_expr()
获取分区边界的可读表达式:
select pg_get_expr(c.relpartbound, c.oid, true)
from pg_class c
where relname = 'tab1_p1';
Run Code Online (Sandbox Code Playgroud)
如果要查看一个表的所有分区(和子分区),可以使用以下命令:
select pt.relname as partition_name,
pg_get_expr(pt.relpartbound, pt.oid, true) as partition_expression
from pg_class base_tb
join pg_inherits i on i.inhparent = base_tb.oid
join pg_class pt on pt.oid = i.inhrelid
where base_tb.oid = 'public.tab1'::regclass;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4077 次 |
最近记录: |