[Oracle] Oracle Series 2--Oracle Data Dictionary

Review of past issues

Preface

1. What is Oracle Data Dictionary

The Data Dictionary is the storage location of Oracle metadata, which collects database objects and basic information required for database operation. Oracle RDBMS uses a data dictionary to record and manage object information and security information. Users can obtain database-related information through the data dictionary for database management, optimization, and maintenance.

2. Contents of data dictionary

The data dictionary includes the following:

  • Definition of all database Schema objects (tables, views, indexes, clusters, synonyms, sequences, procedures, functions, packages, triggers, etc.);
  • Oracle user name, role, permissions and other information;
  • Integrity constraint information;
  • Database space allocation and usage;
  • Field default value;
  • audit information;
  • Other database information.

Oracle dictionary includes four levels, namely internal RDBMS table (X), basic data dictionary table, data dictionary view and dynamic performance view (V), basic data dictionary table, data dictionary view and dynamic performance view (V), basic data Dictionary table, data dictionary view and dynamic performance view (V).

(1) X$ table

The X table is the core part of the Oracle database. It is used to track internal database information and maintain the normal operation of the database. It is dynamically created by the Oracle application when the database is started and does not allow direct access by users other than SYSDBA. The X table is the core part of the Oracle database. It is used to track internal database information and maintain the normal operation of the database. It is dynamically created by the Oracle application when the database is started and does not allow direct access by users other than SYSDBA. XThe table is the core part of the Oracle database . It is used to track internal database information and maintain the normal operation of the database . It is dynamically created by the Oracle application when the database is started . S Y S D B A is not allowed . External users can access directly. The X table is cryptographically named and undocumented. Oracle uses X$ to establish a large number of other views for users to query and manage the database.

(2) Data dictionary table, data dictionary view

Data Dictionary Table is used to store information about tables, indexes, constraints and other database structures.

Table names end with (such as tab)Ending (such as t ab , obj, ts , ts, t s, etc.), create it by running the sql.bsq (under the $ORACLE_HOME/RDBMS/admin directory) script when creating the database.

The users of the data dictionary tables are all sys and exist in the system table space. Oracle has established data dictionary views for these data dictionaries. Oracle names the views DBA_XXXX, ALL_XXXX and USER_XXXX, dictionary views according to the scope of these objects. Records the names of all data dictionary views.

  • user_class view: describes the objects under the current user schema;
  • all_class view: describes information about all objects that the current user has permission to access;
  • dba_class view: includes information about all database objects;

Usually the USER_ class view does not contain the Owner field, and the query returns the object information of the current user.

e.g

SQL> select username from all_users; //查询所有用户
SQL> select username from dba_users; //查询dba用户
SQL> select table_name from user_tables;  //查询当前用户的表
SQL> select table_name from all_tables;  //查询所有用户的表
SQL> select table_name from dba_tables;  //查询包括系统表
SQL> select owner,constraint_name,constraint_type,table_name from user_constraints; 
SQL> select owner,constraint_name,constraint_type,table_name from all_ constraints; 
SQL> select owner,constraint_name,constraint_type,table_name from dba_ constraints ;

(3) Dynamic performance view

The Dynamic Performance (V$) view records database runtime information and statistics.

After the X table is created, Oracle creates the GV table. Oracle creates the GVAfter the table, Oracle created G V and Vview, in GV view , in GVViews, Oracle built GV_̲ and V_ KaTeX parse error: Expected group after '_' at position 48: ... og.sql script after . Through the V_̲view, Oracle isolates the VKaTeX parse error: Expected group after '_' at position 12: view from ordinary users. The permissions of the V_̲view can be granted to other users, but Oracle does not allow anydirect authorization of the V view. Oracle provides some special views to record other view creation methods, such as direct authorization of v views. Oracle provides some special views to record other view creation methods, such as vDirect authorization of views. Oracle provides some special views to record other view creation methods, such as v fixed_view_defition, which allows you to view the definition of the view .

SQL> select view_definition from v\$fixed_view_definition where view_name ='V$NLS_PARAMETERS';

3. Data dictionary application example

(1) Query table information

Querying the DBA_TABLES view can obtain information about all tables, including table names, table spaces, owners, etc. For example, the following query statement can obtain the table names and table spaces of all tables:

SQL> SELECT table_name, tablespace_name FROM dba_tables;

(2) Query index information

Querying the DBA_INDEXES view can obtain information about all indexes, including index name, table to which it belongs, index type, etc. For example, the following query statement can obtain information about all indexes:

SQL> SELECT index_name, table_name, index_type FROM dba_indexes;

(3) Query user information

Querying the DBA_USERS view can obtain information about all users, including user names, default table spaces, temporary table spaces, etc. For example, the following query statement can obtain the username and default tablespace of all users:

SQL> SELECT username, default_tablespace FROM dba_users;

(4) Query table space information

Querying the DBA_TABLESPACES view can obtain all table space information, including table space name, block size, status, etc. For example, the following query statement can obtain the table space names and status of all table spaces:

SQL> SELECT tablespace_name, status FROM dba_tablespaces;

(5) Query information about data files

Query the DBA_DATA_FILES view to obtain information about all data files, including data file names, table space names, file sizes, etc. For example, the following query statement can obtain the data file names and file sizes of all data files:

SQL> SELECT file_name, bytes FROM dba_data_files;

(6) Query the performance data of the database

Query the DBA_HIST_SNAPSHOT view to obtain the historical performance data of the database, including CPU utilization, memory utilization, I/O, etc. For example, the following query statement can obtain the CPU utilization and memory utilization of the database:

SQL> SELECT begin_interval_time, end_interval_time, cpu_usage, memory_usage
FROM dba_hist_sysmetric_summary
WHERE metric_name IN ('CPU Usage Per Sec', 'Memory Usage Per Sec')
ORDER BY begin_interval_time;

Guess you like

Origin blog.csdn.net/u011397981/article/details/132997299