当前位置:网站首页>Oracle advanced (III) detailed explanation of data dictionary
Oracle advanced (III) detailed explanation of data dictionary
2022-07-05 08:48:00 【InfoQ】
One 、Oracle The data dictionary
The data dictionary is
Oracle
A place for storing information about a database , Its purpose is to describe data . For example, the creator information of a table , Create time information , Table space information , User access information, etc . When users encounter difficulties in operating the data in the database, they can access the data dictionary to view the detailed information .
Oracle
There are static and dynamic data dictionaries in . The static data dictionary will not change when users access the data dictionary , But dynamic data dictionary depends on database performance , Reflect some internal information of database operation , Therefore, when accessing this kind of data dictionary, it is often not invariable . These two types of data dictionaries are discussed below .
1.1 Static data dictionary
This kind of data dictionary is mainly composed of tables and views , It should be noted that , Tables in the data dictionary cannot be accessed directly , But you can access the views in the data dictionary . Views in the static data dictionary fall into three categories , They are respectively composed of three prefixes :
user_*
、
all_*
、
dba_*
.
user_*
: This view stores information about the objects owned by the current user .( That is, all objects in the user mode )
all_*
: This attempt stores information about objects that the current user can access .( Anduser_*
comparison ,all_*
You don't need to own the object , You just need to have access to the object )
dba_*
: This view stores information about all objects in the database .( The premise is that the current user has access to these databases , Generally speaking, you must have administrator rights )
As can be seen from the above description , The data stored between the three will definitely overlap , In fact, in addition to the different access ranges ( Because the permissions are different , So the scope of access objects is different ), Others are consistent . say concretely , Because the data dictionary view is made up of
SYS
( System users ) Owned , So by default , Only SYS And have DBA Users with system permissions can see all views . No, DBA Users with permissions can only see
user_*
and
all_*
View . If not granted relevant
SELECT
permissions , They can't see
dba_*
View's .
Because the three have similarities , Let's say
user_
As an example, this paper introduces several commonly used static views
user_users
View : It mainly describes the information of the current user , It mainly includes the current user name 、 account id、 Account status 、 Table space name 、 Creation time, etc . For example, execute the following command to return this information .
select * from user_users
user_tables
View : It mainly describes the information of all tables owned by the current user , It mainly includes table name 、 Table space name 、 Cluster name, etc . Through this view, you can clearly understand which tables the current user can operate . The execution order is :select * from user_tables
user_objects
View : It mainly describes the information of all objects owned by the current user , Objects include tables 、 View 、 stored procedure 、 trigger 、 package 、 Indexes 、 Sequence, etc . This view is better thanuser_tables
The view is more comprehensive . for example , You need to get a file named “package1” Information about the object type and its state , You can execute the following command :select object_type,status from user_objects where object_name=upper(‘package1’);
Be careful :upper Use , All objects in the data dictionary are capitalized , and PL/SQL It's not case sensitive , So in practice, we must pay attention to case matching .
user_tab_privs
View : This view mainly stores the permission information of all tables under the current user . such as , In order to understand the current user's response to table1 Permission information of , You can execute the following command :
select * from user_tab_privs where table_name=upper('table1')
After knowing the permissions of the current user on this table, you can clearly know , What operations can be performed , Which operations cannot be performed .
The front views are user_ At the beginning , Actually all_ The beginning is exactly the same , Only the listed information is the object that the current user can access, not the object owned by the current user . about dba_ The first one needs administrator permission , Other uses are exactly the same , I won't go into that here .
1.2 Dynamic data dictionary
Oracle Contains a number of potential applications by system administrators such as SYS Maintained tables and views , Because when databases are running, they are constantly updated , So we call them dynamic data dictionaries ( Or dynamic performance view ). These views provide information about the operation of memory and disk , So we can only access them read-only, not modify them .
Oracle These dynamic performance views are based on
v$
The first view , such as
v$access
. Here are some main dynamic performance views .
v$access
: This view shows the database objects locked in the database and the session objects accessing these objects (session object ).
Run the following command :
select * from v$access
give the result as follows :( Because there are many records , So here is only an excerpt of some records )
SID
OWNER OBJECT TYPE
27 DKH V$ACCESS CURSOR
27 PUBLIC V$ACCESS SYNONYM
27 SYS DBMS_APPLICATION_INFO PACKAGE
27 SYS GV$ACCESS VIEW
v$session
: This view lists the details of the current session . Because there are many fields in this view , No detailed fields are listed here , For more information , Can be directly in sql*plus Type... At the command line :desc v$session
that will do .
v$active_instance
: This view mainly describes the information of the active instances under the current database . Still usable select Statement to observe the information .
v$context
: This view lists the attribute information of the current session . For example, the namespace 、 Property value, etc .
1.3 Summary
Above is Oracle The basic content of data dictionary , There are also many useful views that cannot be explained here because of space , I hope you will pay more attention to it in your daily use . All in all , Make good use of data dictionary technology , It can enable database developers to better understand the overall picture of the database , So for database optimization 、 Management is of great help .
Two 、Oracle Data dictionary commonly used in
These data dictionaries are listed below , Both in Oracle 11g R1 On , adopt Oracle Sql Developer Tested , All pass . Many of these data dictionaries must be system Or is it sysdba Users can only use it after logging in .
--- Basic information of database instances
desc v$instance;
select * from v$instance;
-- Basic information of data file
desc v$datafile;
select * from v$datafile;
desc dba_data_files;
select file_name,file_id,tablespace_name,bytes,blocks, tatus,online_status from dba_data_files;
-- Basic information of temporary files
desc dba_temp_files;
select file_name,file_id,tablespace_name,status, from dba_temp_files;
-- Basic information of control document
desc v$controlfile;
select name,status,is_recovery_dest_file, block_size,file_size_blks from v$controlfile;
-- Basic information of log file
desc v$logfile;
select group#,status,type,member,is_recovery_dest_file from v$logfile;
边栏推荐
- Basic number theory - fast power
- Digital analog 2: integer programming
- Business modeling | process of software model
- 资源变现小程序添加折扣充值和折扣影票插件
- Basic number theory -- Euler function
- Guess riddles (8)
- Bit operation related operations
- Search data in geo database
- How to manage the performance of R & D team?
- 【日常训练】1200. 最小绝对差
猜你喜欢
随机推荐
Chapter 18 using work queue manager (1)
Illustration of eight classic pointer written test questions
golang 基础 ——map、数组、切片 存放不同类型的数据
Meta标签详解
图解网络:什么是网关负载均衡协议GLBP?
696. 计数二进制子串
The first week of summer vacation
Business modeling of software model | stakeholders
EA introduction notes
ROS learning 4 custom message
Guess riddles (9)
Guess riddles (8)
Dynamic dimensions required for input: input, but no shapes were provided. Automatically overriding
Guess riddles (3)
Arduino operation stm32
Programming implementation of ROS learning 6 -service node
[牛客网刷题 Day4] JZ35 复杂链表的复制
Pytorch entry record
MATLAB skills (28) Fuzzy Comprehensive Evaluation
容易混淆的基本概念 成员变量 局部变量 全局变量