当前位置:网站首页>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_usersView : 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_tablesView : 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_objectsView : 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_tablesThe 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_privsView : 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$sessionthat 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;
边栏推荐
- Typical low code apaas manufacturer cases
- Arduino+a4988 control stepper motor
- Business modeling | process of software model
- Lori remote control commissioning record
- Old Wang's esp8266 and old Wu's ws2818 light strip
- RT-Thread内核快速入门,内核实现与应用开发学习随笔记
- 整形的分类:short in long longlong
- Run菜单解析
- kubeadm系列-00-overview
- TypeScript手把手教程,简单易懂
猜你喜欢
随机推荐
JS asynchronous error handling
Explore the authentication mechanism of StarUML
Business modeling of software model | object modeling
Cmder of win artifact
RT-Thread内核快速入门,内核实现与应用开发学习随笔记
Programming implementation of ROS learning 5-client node
使用arm Neon操作,提高内存拷贝速度
[牛客网刷题 Day4] JZ32 从上往下打印二叉树
The first week of summer vacation
猜谜语啦(11)
ROS learning 4 custom message
An enterprise information integration system
kubeadm系列-02-kubelet的配置和启动
Illustration of eight classic pointer written test questions
Basic number theory - factors
【日常训练】1200. 最小绝对差
OpenFeign
One dimensional vector transpose point multiplication np dot
Guess riddles (9)
Guess riddles (3)



![[牛客网刷题 Day4] JZ55 二叉树的深度](/img/f7/ca8ad43b8d9bf13df949b2f00f6d6c.png)



