碰巧在墨天轮上看资料就看到了eygle的这篇文章《如何获得 Oracle 分区索引的类型 - 全局分区索引、本地分区索引》,秉承了eygle大神一如既往的风格,文章“短小”,但是“精悍”,从我看eygle的第一本书开始,就记住了他这句“由点及面”,不仅在数据库领域中,在其他工作领域,这种学习方法,都是适用的。正所谓“授之以鱼不如授之以渔”。
Oracle数据库针对分区的信息,通过多个数据字典视图来维护,所以在获取信息时,经常会困惑DBA们。
例如,如何获取分区索引的类型,如何判断一个索引,是全局分区索引,还是本地分区索引?
通过DBA_PART_INDEXES中的LOCALITY字段就可以判断:
SQL> select distinct (locality) from dba_part_indexes;
LOCALI
------
LOCAL
LOCAL意味着是本地索引;GLOBAL则意味着是全局索引。
DBA_PART_INDEXES和ALL_PART_INDEXES、USER_PART_INDEXES视图的字段相同,分别展示的是数据库(DBA级别)、用户权限级别(ALL)和用户所属级别(USER)的分区索引信息。
至于分区类型等,可以通过这个视图查询获得:
SQL> select TABLE_NAME,PARTITIONING_TYPE,LOCALITY from dba_part_indexes where rownum < 10;
TABLE_NAME PARTITION LOCALI
-------------------------------------------------- --------- ------
STREAMS$_APPLY_SPILL_MSGS_PART LIST LOCAL
STREAMS$_APPLY_SPILL_MSGS_PART LIST LOCAL
LOGMNRC_CONCOL_GG RANGE LOCAL
LOGMNRC_CON_GG RANGE LOCAL
LOGMNRC_CON_GG RANGE LOCAL
LOGMNRC_CON_GG RANGE LOCAL
LOGMNRC_GSBA RANGE LOCAL
LOGMNRC_GSII RANGE LOCAL
LOGMNRC_GTCS RANGE LOCAL
视图信息引入如下,供参考:
Column | Datatype | NULL | Description |
|
|
| Owner of the partitioned index |
|
|
| Name of the partitioned index |
|
|
| Name of the partitioned table |
|
| Type of partitioning method:
| |
|
| Type of composite partitioning method:
| |
|
|
| Number of partitions in the index |
|
| For a composite-partitioned index, the default number of subpartitions, if specified | |
|
|
| Number of columns in the partitioning key |
|
| For a composite-partitioned index, the number of columns in the subpartitioning key | |
|
| Indicates whether the partitioned index is local ( | |
|
| Indicates whether the partitioned index is | |
|
| For a local index, the default tablespace to be used when adding or splitting a table partition | |
|
|
| For a local index, the default |
|
|
| For a local index, the default |
|
|
| For a local index, the default |
|
|
| For a local index, the default |
|
|
| For a local index, the default |
|
|
| For a local index, the default |
|
|
| For a local index, the default |
|
|
| For a local index, the default |
|
|
| For a local index, the default |
|
|
| For a local index, the default |
|
| For a local index, the default | |
|
| For a local index, the default buffer pool to be used when adding a table partition | |
|
| Default parameter string for domain indexes |