详解Oracle数据字典
Oracle通过数据字典来管理和展现数据库信息,数据字典通常储存数据库的元数据,是数据库的ldquo;数据库rdquo;。通常说的数据字
Oracle通过数据字典来管理和展现数据库信息,数据字典通常储存数据库的元数据,是数据库的“数据库”。通常说的数据字典由4部分组成:内部RDBMS(X$)表、数据字典表、动态性能视图(V$)和(静态)数据字典视图。(两表两视图)
1,内部RDBMS(X$)表
X$表示Oracle数据库的核心部分,这些表用于跟踪数据库内部信息,维持数据库的正常运行。X$表是加密命名的,而且Oracle不做文档说明。X$表是Oracle数据库的运行基础,在数据库启动时由Oracle应用程序动态创建。比如我们熟知的X$BH、X$KSMSP等。研究这些表的最好的办法就是借用Oracle的autotrace功能(set autotrace trace explain)。
2,数据字典表
数据字典表(Data dictionary table)用以存储表、索引、约束以及其它数据库结构的信息,这些对象通常以“$”结尾(例如:TAB$、OBJ$、TS$等),在创建数据库的时候通过运行$ORACLE_HOME/rdbms/admin/sql.bsq脚本来创建。sql.bsq是一个非常重要的文件,其中包含了数据字典表的定义及注释说明,应仔细阅读研究。
比如我们经常使用的V$DBA_OBJECT视图就是基于V$OBJ创建的;再比如,当用户创建一张表的时候,Oracle将会在后台执行一系列的内部操作,比如向objV$表中插入数据、向tab$表中记录表数据等。Oracle通过将DDL解析成DML操作,并且将这些操作记录在数据字典表中,那么我们当然可以通过反向解析得到原始的创建语句,从Oracle 9i 开始,一个新的工具包 DBMS_METADATA 就可以完成该功能:
3,静态数据字典视图
由于X$表和数据字典表通常不能直接被用户访问,Oracle创建了静态数据字典视图来提供用户对于数据字典信息的访问,由于这些信息通常相对稳定,不能直接修改,所以又被称为静态数据字典视图。静态数据字典视图在创建数据库时由$ORACLE_HOME/rdbms/admin/catagory.sql脚本创建。
静态数据字典视图按照前缀的不同通常分成三类:
● USER_:用户所拥有的相关对象信息;
● ALL_:用于有权限访问的所有对象的信息;
● DBA_:数据库所有相关对象的信息,用于需要有 select any table 的权限才能访问。
通过三类视图在本质上是为了实现权限控制。在Oracle数据库中,每个用户与方案(Schema)是对应的,Schema是用户所拥有的对象的集合。数据库通过Schema将不同用户的对象隔离开来,用户可以自由的访问自己的对象,但是要访问其他Schema对象就需要相关的授权。
4,动态性能视图
动态性能视图记录了数据库运行时信息和统计数据,大部分动态性能视图被实时更新以及反映数据库当前状态。在数据库启动时,Oracle动态创建X$表,在此基础上,,Oracle创建了GV$和V$视图,GV$即Global V$,除了一些特例外,每个V$都对应一个GV$。GV$产生是为了OPS/RAC环境的需要,每个V$都是基于GV$的,只是GV$多了INST_ID列来显示实例ID。
(1)如何查看一个视图的底层创建语句?
Oracle提供了一些特殊的视图用以记录其他视图的创建方式,v$fixed_view_definition就是其中之一。
(2)查询V$视图时,报的错却是V_$视图不存在,V_$视图不是基于V$视图创建的吗,怎么反向报错了?
为了防止普通用户的误操作,Oracle对通过软件机制对V$视图的访问做了限制,它不允许普通用户直接访问V$视图,但我们平时不是经常访问吗?这其实是Oracle引入了V_$视图。在建立V$视图后,Oracle就建立了V_$视图,随后为V_$视图建立了与V$视图同名的共用同义词。这些工作都是通过catalog.sql脚本(该脚本位于$ORACLE_HOME/rdbms/admin/目录下)实现的。
如:
create or replace view v_$fixed_table as select * from v$fixed_table;
create or replace public synonym v$fixed_table for v_$fixed_table; --同名同义词
也就是说,大部分用户访问的V$对象,并不是视图,而是执行V_$视图的同义词;而V_$视图时基于真正V$视图创建的。
本文永久更新链接地址:

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Go language is an efficient, concise and easy-to-learn programming language. It is favored by developers because of its advantages in concurrent programming and network programming. In actual development, database operations are an indispensable part. This article will introduce how to use Go language to implement database addition, deletion, modification and query operations. In Go language, we usually use third-party libraries to operate databases, such as commonly used sql packages, gorm, etc. Here we take the sql package as an example to introduce how to implement the addition, deletion, modification and query operations of the database. Assume we are using a MySQL database.

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

Hibernate polymorphic mapping can map inherited classes to the database and provides the following mapping types: joined-subclass: Create a separate table for the subclass, including all columns of the parent class. table-per-class: Create a separate table for subclasses, containing only subclass-specific columns. union-subclass: similar to joined-subclass, but the parent class table unions all subclass columns.

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

HTML cannot read the database directly, but it can be achieved through JavaScript and AJAX. The steps include establishing a database connection, sending a query, processing the response, and updating the page. This article provides a practical example of using JavaScript, AJAX and PHP to read data from a MySQL database, showing how to dynamically display query results in an HTML page. This example uses XMLHttpRequest to establish a database connection, send a query and process the response, thereby filling data into page elements and realizing the function of HTML reading the database.

PHP is a back-end programming language widely used in website development. It has powerful database operation functions and is often used to interact with databases such as MySQL. However, due to the complexity of Chinese character encoding, problems often arise when dealing with Chinese garbled characters in the database. This article will introduce the skills and practices of PHP in handling Chinese garbled characters in databases, including common causes of garbled characters, solutions and specific code examples. Common reasons for garbled characters are incorrect database character set settings: the correct character set needs to be selected when creating the database, such as utf8 or u

Through the Go standard library database/sql package, you can connect to remote databases such as MySQL, PostgreSQL or SQLite: create a connection string containing database connection information. Use the sql.Open() function to open a database connection. Perform database operations such as SQL queries and insert operations. Use defer to close the database connection to release resources.
