DB2 Version 10.1 for Linux, UNIX, and Windows

Oracle data dictionary-compatible views

When you set the DB2_COMPATIBILITY_VECTOR registry variable to support Oracle data dictionary-compatible views, the views are automatically created when you create a database.

You enable Oracle data dictionary-compatible view support by setting the DB2_COMPATIBILITY_VECTOR registry variable to hexadecimal value 0x400 (bit position 11), and then stop and restart the instance to have the new setting take effect.
db2set DB2_COMPATIBILITY_VECTOR=400
db2stop
db2start
To take full advantage of the DB2 compatibility features for Oracle applications, the recommended setting for the DB2_COMPATIBILITY_VECTOR is ORA, which sets all of the compatibility bits.

The data dictionary is a repository for database metadata. The data dictionary views are self-describing. The DICTIONARY view returns a listing of all data dictionary views with comments that describe the content of each view. The DICT_COLUMNS view returns a list of all columns in all data dictionary views. With these two views, you can determine what information is available and how to access it.

There are three different versions of each data dictionary view, and each version is identified by the prefix of the view name. Not all versions apply to each view.

The data dictionary definition includes CREATE VIEW, CREATE PUBLIC SYNONYM, and COMMENT statements for each view that is compatible with the Oracle data dictionary. The views, which are created in the SYSIBMADM schema, are listed in Table 1.

Table 1. Oracle data dictionary-compatible views
Category Defined views
General

DICTIONARY, DICT_COLUMNS
USER_CATALOG, DBA_CATALOG, ALL_CATALOG
USER_DEPENDENCIES, DBA_DEPENDENCIES, ALL_DEPENDENCIES
USER_OBJECTS, DBA_OBJECTS, ALL_OBJECTS
USER_SEQUENCES, DBA_SEQUENCES, ALL_SEQUENCES
USER_TABLESPACES, DBA_TABLESPACES

Tables or views

USER_CONSTRAINTS, DBA_CONSTRAINTS, ALL_CONSTRAINTS
USER_CONS_COLUMNS, DBA_CONS_COLUMNS, ALL_CONS_COLUMNS
USER_INDEXES, DBA_INDEXES, ALL_INDEXES
USER_IND_COLUMNS, DBA_IND_COLUMNS, ALL_IND_COLUMNS
USER_TAB_PARTITIONS, DBA_TAB_PARTITIONS, ALL_TAB_PARTITIONS
USER_PART_TABLES, DBA_PART_TABLES, ALL_PART_TABLES
USER_PART_KEY_COLUMNS, DBA_PART_KEY_COLUMNS, ALL_PART_KEY_COLUMNS
USER_SYNONYMS, DBA_SYNONYMS, ALL_SYNONYMS
USER_TABLES, DBA_TABLES, ALL_TABLES
USER_TAB_COMMENTS, DBA_TAB_COMMENTS, ALL_TAB_COMMENTS
USER_TAB_COLUMNS, DBA_TAB_COLUMNS, ALL_TAB_COLUMNS
USER_COL_COMMENTS, DBA_COL_COMMENTS, ALL_COL_COMMENTS
USER_TAB_COL_STATISTICS, DBA_TAB_COL_STATISTICS, ALL_TAB_COL_STATISTICS
USER_VIEWS, DBA_VIEWS, ALL_VIEWS
USER_VIEW_COLUMNS, DBA_VIEW_COLUMNS, ALL_VIEW_COLUMNS

Programming objects

USER_PROCEDURES, DBA_PROCEDURES, ALL_PROCEDURES
USER_SOURCE, DBA_SOURCE, ALL_SOURCE
USER_TRIGGERS, DBA_TRIGGERS, ALL_TRIGGERS
USER_ERRORS, DBA_ERRORS, ALL_ERRORS
USER_ARGUMENTS, DBA_ARGUMENTS, ALL_ARGUMENTS

Security

USER_ROLE_PRIVS, DBA_ROLE_PRIVS, ROLE_ROLE_PRIVS
SESSION_ROLES
USER_SYS_PRIVS, DBA_SYS_PRIVS, ROLE_SYS_PRIVS
SESSION_PRIVS
USER_TAB_PRIVS, DBA_TAB_PRIVS, ALL_TAB_PRIVS, ROLE_TAB_PRIVS
USER_TAB_PRIVS_MADE, ALL_TAB_PRIVS_MADE
USER_TAB_PRIVS_RECD, ALL_TAB_PRIVS_RECD
DBA_ROLES

Examples

The following examples show how to enable, get information about, and use data dictionary-compatible views for a database that is named MYDB:
  • Enable the creation of data dictionary-compatible views:
       db2set DB2_COMPATIBILITY_VECTOR=ORA
       db2stop
       db2start
       db2 create db mydb
  • Determine what data dictionary-compatible views are available:
       connect to mydb
       select * from dictionary
  • Use the USER_SYS_PRIVS view to show all the system privileges that the current user has been granted:
       connect to mydb
       select * from user_sys_privs
  • Determine the column definitions for the DBA_TABLES view:
       connect to mydb
       describe select * from dba_tables