Sunday, 13 October 2013

How to find out fast the partitioning keys in tables or indexes?

The key in this question is the word "fast"; there are many ways to find the partitioning key for a table or an index: using dbms_metadata.get_ddl, export/import using indexfile, ussing expdp and impdp, but the fastest way is to query the views below:

DBA_PART_KEY_COLUMNS
DBA_SUBPART_KEY_COLUMNS
USER_PART_KEY_COLUMNS
USER_SUBPART_KEY_COLUMNS
ALL_PART_KEY_COLUMNS
ALL_SUBPART_KEY_COLUMNS


They provide info for subpartitions also.

Example:

SQL> select * from DBA_PART_KEY_COLUMNS
  2  where owner='CUSTO'
  3   and NAME='TRB1_AUDIT_SUB_LOG'
  4  order by COLUMN_POSITION;

OWNER                          NAME                           OBJEC COLUMN_NAME                    COLUMN_POSITION
------------------------------ ------------------------------ ----- ------------------------------ ---------------
CUSTO                       MY_AUDIT_LOG             TABLE PERIOD_KEY                                   1
CUSTO                       MY_AUDIT_LOG             TABLE SOURCE_MEMBER_ID                             2
CUSTO                       MY_AUDIT_LOG             TABLE SUB_APPL_ID                                  3
CUSTO                       MY_AUDIT_LOG             TABLE PROCESS_TYPE_IND                             4


No comments:

Post a Comment