Managing Objects with Data Dictionary Views
What this domain tests
Data dictionary views describe database objects. The exam tests USER_, ALL_, and DBA_ views and the specific views used to inspect tables, columns, constraints, indexes, views, sequences, and synonyms.
Core rules
USER_views show objects owned by the current user.ALL_views show objects the current user can access, including owned objects.DBA_views show all objects and require privileges such asSELECT_CATALOG_ROLEorDBA.USER_TABLESlists tables;USER_TAB_COLUMNSlists columns with data types and nullability.USER_CONSTRAINTSandUSER_CONS_COLUMNSdescribe constraints and their columns.USER_INDEXESandUSER_IND_COLUMNSdescribe indexes;USER_VIEWSstores view text;USER_SEQUENCESshows sequence settings;USER_SYNONYMSlists private synonyms.USER_OBJECTSlists object names and types.DICTIONARYandDICT_COLUMNSdescribe the dictionary itself.- Object names are stored in uppercase unless created with quoted identifiers.
Worked example
SELECT column_name, data_type, nullable FROM user_tab_columns WHERE table_name = 'EMPLOYEES' ORDER BY column_id;
USER_TAB_COLUMNS contains one row per column of each table owned by the current user. The table name must match the stored case, which is usually uppercase. COLUMN_ID gives the column's position, so ordering by it reproduces the table's column order.
Traps
- Querying
USER_TABLESfor another user's table; useALL_TABLESorDBA_TABLES. - Comparing
table_name = 'employees'when the object was created unquoted and stored asEMPLOYEES. - Confusing
USER_INDEXESwithUSER_IND_COLUMNS; the latter has the indexed columns. - Expecting
USER_SYNONYMSto include public synonyms; it does not. - Assuming
USER_OBJECTScontains column-level details; useUSER_TAB_COLUMNS.