PolarDB PostgreSQL版(兼容Oracle)提供了系统视图,您可以使用系统视图来查看分区表的结构信息。
PolarDB PostgreSQL版(兼容Oracle)提供了以下几个系统视图和系统函数,供您查看数据库中分区表的相关信息。
ALL_PART_TABLES
返回字段说明
列名  | 描述  | 
owner  | 表的所有者。  | 
schema_name  | 表所在的schema。  | 
table_name  | 表名。  | 
partitioning_type  | 分区类型,取值如下: 
  | 
subpartitioning_type  | 子分区类型,取值如下: 
  | 
partition_count  | 分区数。  | 
def_subpartition_count  | 默认子分区数,默认值为0。  | 
partitioning_key_count  | 分区根据子句列出的列数。  | 
subpartitioning_key_count  | 子分区根据子句列出的列数。  | 
status  | 该列始终有效。  | 
def_tablespace_name  | 该列始终为NULL。  | 
def_pct_free  | 该列始终为NULL。  | 
def_pct_used  | 该列始终为NULL。  | 
def_ini_trans  | 该列始终为NULL。  | 
def_max_trans  | 该列始终为NULL。  | 
def_initial_extent  | 该列始终为NULL。  | 
def_next_extent  | 该列始终为NULL。  | 
def_min_extents  | 该列始终为NULL。  | 
def_max_extents  | 该列始终为NULL。  | 
def_pct_increase  | 该列始终为NULL。  | 
def_freelists  | 该列始终为NULL。  | 
def_freelist_groups  | 该列始终为NULL。  | 
def_logging  | 该列始终为YES。  | 
def_compression  | 该列始终为NONE。  | 
def_buffer_pool  | 该列将始终为DEFAULT。  | 
ref_ptn_constraint_name  | 该列始终为NULL。  | 
interval  | 该列始终为NULL。  | 
示例
 owner | schema_name | table_name | partitioning_type | subpartitioning_type | partition_count | def_subpartition_count | partitioning_key_count | subpartitioning_key_count | status | def_ta
blespace_name | def_pct_free | def_pct_used | def_ini_trans | def_max_trans | def_initial_extent | def_next_extent | def_min_extents | def_max_extents | def_pct_increase | def_freelists | de
f_freelist_groups | def_logging | def_compression | def_buffer_pool | ref_ptn_constraint_name | interval 
-------+-------------+------------+-------------------+----------------------+-----------------+------------------------+------------------------+---------------------------+--------+-------
--------------+--------------+--------------+---------------+---------------+--------------------+-----------------+-----------------+-----------------+------------------+---------------+---
------------------+-------------+-----------------+-----------------+-------------------------+----------
 PolarDB   | PUBLIC      | IDXPART    | HASH              | NONE                 |               2 |                      0 |                      1 |                           | VALID  |       
              |              |              |               |               |                    |                 |                 |                 |                  |               |   
                  | YES         | NONE            | DEFAULT         |                         | 
 PolarDB   | PUBLIC      | SALES      | RANGE             | NONE                 |               4 |                      0 |                      1 |                           | VALID  |       
              |              |              |               |               |                    |                 |                 |                 |                  |               |   
                  | YES         | NONE            | DEFAULT         |                         | 
(2 rows)ALL_TAB_PARTITIONS
返回字段说明
列名  | 描述  | 
table_owner  | 表的所有者。  | 
schema_name  | 表所在的schema名称。  | 
table_name  | 表名。  | 
composite  | 
  | 
partition_name  | 分区名。  | 
subpartition_count  | 子分区数。  | 
high_value  | RANGE分区的分区限值,或LIST分区的分区值。  | 
high_value_length  | 高分区值的长度。  | 
partition_position  | 该列始终为NULL。  | 
tablespace_name  | 表空间名。  | 
pct_free  | 该列始终为0。  | 
pct_used  | 该列始终为0。  | 
ini_trans  | 该列始终为0。  | 
max_trans  | 该列始终为0。  | 
initial_extent  | 该列始终为NULL。  | 
next_extent  | 该列始终为NULL。  | 
min_extent  | 该列始终为0。  | 
max_extent  | 该列始终为0。  | 
pct_increase  | 该列始终为0。  | 
freelists  | 该列始终为NULL。  | 
freelist_groups  | 该列始终为NULL。  | 
logging  | 该列始终为YES。  | 
compression  | 该列始终为NONE。  | 
num_rows  | 分区中的大约行数。  | 
blocks  | 分区中的大约块数。  | 
empty_blocks  | 该列始终为NULL。  | 
avg_space  | 该列始终为NULL。  | 
chain_cnt  | 该列始终为NULL。  | 
avg_row_len  | 该列始终为NULL。  | 
sample_size  | 该列始终为NULL。  | 
last_analyzed  | 该列始终为NULL。  | 
buffer_pool  | 该列始终为NULL。  | 
global_stats  | 该列始终为YES。  | 
user_stats  | 该列始终为NO。  | 
backing_table  | 该分区支持的表的OID。  | 
ALL_TAB_SUBPARTITIONS
返回字段说明
列名  | 描述  | 
table_owner  | 表的所有者。  | 
schema_name  | 表所在的schema名称。  | 
table_name  | 表名。  | 
partition_name  | 分区名。  | 
subpartition_name  | 子分区名。  | 
high_value  | RANGE子分区的子分区限值,或LIST子分区的子分区值。  | 
high_value_length  | 高分区值的长度。  | 
subpartition_position  | 该列始终为NULL。  | 
tablespace_name  | 表空间名。  | 
pct_free  | 该列始终为0。  | 
pct_used  | 该列始终为0。  | 
ini_trans  | 该列始终为0。  | 
max_trans  | 该列始终为0。  | 
initial_extent  | 该列始终为NULL。  | 
next_extent  | 该列始终为NULL。  | 
min_extent  | 该列始终为0。  | 
max_extent  | 该列始终为0。  | 
pct_increase  | 该列始终为0。  | 
freelists  | 该列始终为NULL。  | 
freelist_groups  | 该列始终为NULL。  | 
logging  | 该列始终为YES。  | 
compression  | 该列始终为NONE。  | 
num_rows  | 子分区中的大约行数。  | 
blocks  | 子分区中的大约块数。  | 
empty_blocks  | 该列始终为NULL。  | 
avg_space  | 该列始终为NULL。  | 
chain_cnt  | 该列始终为NULL。  | 
avg_row_len  | 该列始终为NULL。  | 
sample_size  | 该列始终为NULL。  | 
last_analyzed  | 该列始终为NULL。  | 
buffer_pool  | 该列始终为NULL。  | 
global_stats  | 该列始终为YES。  | 
user_stats  | 该列始终为NO。  | 
backing_table  | 该子分区支持的表的OID。  | 
ALL_PART_KEY_COLUMNS
返回字段说明
列名  | 描述  | 
owner  | 表的所有者。  | 
schema_name  | 表所在的schema名称。  | 
name  | 表名。  | 
object_type  | 该列始终为TABLE。  | 
column_name  | 分区键列的名称.  | 
column_position  | 该列在分区键中的位置(第一列的列位置为1,第二列的列位置为2...)。  | 
ALL_SUBPART_KEY_COLUMNS
返回字段说明
列名  | 描述  | 
owner  | 表的所有者。  | 
schema_name  | 表所在的schema名称。  | 
name  | 表名。  | 
object_type  | 该列始终为TABLE。  | 
column_name  | 分区键列的名称.  | 
column_position  | 该列在子分区键中的位置(第一列的列位置为1,第二列的列位置为2...)。  |