Data Dictionary in Oracle

Posted by random1 on Fri, 21 Jun 2019 18:25:26 +0200

data dictionary
The data dictionary is where oracle stores information about the database. Almost all system and object information can be queried in the data dictionary.The data dictionary is the information core of the oracle database system. It is a collection of tables and views that provide information about the database. These tables and views are read-only.It is built with the database, and the data dictionary updates automatically when the database performs a specific action.Data Overview and Data Dictionary to record, verify, and manage ongoing operations.
In oracle, the sys user is the owner of the data dictionary, which guarantees that no user can change the schema object or rows in the data dictionary in sys mode within the system table space system of all databases.That is, the data dictionary can only be queried and cannot be modified manually.

Include:
Basic table: Describes database information and can only be modified by the database server
User table: User-defined table

Data Dictionary Naming Rules

prefix Explain
USER User's own
ALL User-accessible
DBA Administrator View
V$ Performance-related data

How to use Data Dictionary View
Starting with DICTIONARY, this data object contains the table name and description of the data dictionary

DESCRIBE DICTIONARY

SELECT *
FROM   dictionary
WHERE  table_name = 'USER_OBJECTS';

USER_OBJECTS and ALL_OBJECTS
USER_OBJECTS:
Query USER_OBJECTS to determine all objects created by the current user
The following information is available:
Date created
Date of last modification
Status (valid or invalid)

SELECT object_name, object_type, created, status
FROM   user_objects
ORDER BY object_type;

ALL_OBJECTS:
You can determine which data objects the current user can access by querying ALL_OBJECTS

Table information

DESCRIBE user_tables

SELECT table_name
FROM   user_tables;

Column information

DESCRIBE user_tab_columns

SELECT column_name, data_type, data_length,
       data_precision, data_scale, nullable
FROM   user_tab_columns
WHERE  table_name = 'EMPLOYEES'; 

constraint
USER_CONSTRAINTS: Constraints on the current user table
Column Constraints Created by Current User of USER_CONS_COLUMNS

DESCRIBE user_constraints

SELECT constraint_name, constraint_type,
       search_condition, r_constraint_name, 
       delete_rule, status
FROM   user_constraints
WHERE  table_name = 'EMPLOYEES'; 


DESCRIBE user_cons_columns

SELECT constraint_name, column_name
FROM   user_cons_columns
WHERE  table_name = 'EMPLOYEES'; 

view

DESCRIBE user_views

SELECT DISTINCT view_name FROM user_views;

SELECT text FROM user_views 
WHERE view_name = 'EMP_DETAILS_VIEW';

sequence

DESCRIBE user_sequences

Query Sequence Information via USER_SEQUENCES

SELECT  sequence_name, min_value, max_value, 
    increment_by, last_number
FROM    user_sequences;

LAST_NUMBER indicates the next available value when NOCAHCE is not used

Synonym

DESCRIBE user_synonyms

SELECT * 
FROM   user_synonyms;

Add comments to tables
Use the COMMENT statement to add a comment to a table or column:

COMMENT ON TABLE employees
IS 'Employee Information';

Note Related Views:
ALL_COL_COMMENTS
USER_COL_COMMENTS
ALL_TAB_COMMENTS
USER_TAB_COMMENTS
Comments on Query Table
select * from user_tab_comments where table_name= '???';

Topics: Database Oracle