学习网考试学习资料

Gzu521.com

深入了解Oracle的数据字典(1)

计算机软件水平考试   点击:次   发布时间:2006-12-30   【字体: 】   来源:Gzu521.com
Gzu521.com我的学习网
   首先,Oracle的字典表和视图基本上可以分为三个层次。

    1.x$表

    这一部分表是oracle数据库的运行基础,在数据库启动时由oracle应用程序动态创建。 -S~2QH@zDOux(%c [ 本 资 料 来 源 于 贵 州 学 习 网 IT认证计算机软件水平考试 http://Www.gzU521.com ] -S~2QH@zDOux(%c

    这部分表对数据库来说至关重要,所以oracle不允许sysdba之外的用户直接访问,显示授权不被允许。

    如果显示授权你会收到如下错误:

    sql> grant select on x$ksppi to eygle;
    grant select on x$ksppi to eygle
    *
    error at line 1:
    ora-02030: can only select from fixed tables/views

    2.gv$和v$视图

    从oracle8开始,gv$视图开始被引入,其含义为global v$.

    除了一些特例以外,每个v$视图都有一个对应的gv$视图存在。

    gv$视图的产生是为了满足ops环境的需要,在ops环境中,查询gv$视图返回所有实例信息,而每个v$视图基于gv$视图,增加了inst_id列判断后建立,只包含当前连接实例信息。

    注意,每个v$视图都包含类似语句:

    where inst_id = userenv(’instance’)

    用于限制返回当前实例信息。

    我们从gv$fixed_table和v$fixed_table开始

    sql> select view_definition from v_$fixed_view_definition

    where view_name=’v$fixed_table’;

    view_definition

    ----------------------------------------------------------

    select name , object_id , type , table_num from gv$fixed_table

    where inst_id = userenv(’instance’)

    这里我们看到v$fixed_table基于gv$fixed_table创建。

    sql> select view_definition from v_$fixed_view_definition rmU 7yw [!) D[ 此文转贴于我的学习网IT认证计算机软件水平考试 http://www.Gzu521.com]rmU 7yw [!) D

    where view_name=’gv$fixed_table’;

    view_definition

    -----------------------------------------------------------

    select inst_id,kqftanam, kqftaobj, ’table’, indx from x$kqfta

    union all

    select inst_id,kqfvinam, kqfviobj, ’view’, 65537 from x$kqfvi

    union all

    select inst_id,kqfdtnam, kqfdtobj, ’table’, 65537 from x$kqfdt

    这样我们找到了gv$fixed_table视图的创建语句,该视图基于x$表创建。

    3.gv_$,v_$视图和v$,gv$同义词

    这些视图是通过catalog.ql创建。

    当catalog.sql运行时:

    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;

    create or replace view gv_$fixed_table as select * from gv$fixed_table;

    create or replace public synonym gv$fixed_table for gv_$fixed_table;

    我们注意到,第一个视图v_$和gv_$首先被创建,v_$和gv_$两个视图。

    然后基于v_$视图的同义词被创建。

    所以,实际上通常我们访问的v$视图,其实是指向v_$视图的同义词。

    而v_$视图是基于真正的v$视图(这个视图是基于x$表建立的)。

    而v$fixed_view_definition视图是我们研究oracle对象关系的一个入口,仔细理解oracle的数据字典机制,有助于深入了解和学习oracle数据库知识。

    4.再进一步

    1).x$表

    关于x$表,其创建信息我们也可以从数据字典中一窥究竟。

    首先我们考察bootstrap$表,该表中记录了数据库启动的基本及驱动信息。

    sql> select * from bootstrap$;
    line# obj# sql_text
    ------------------------------------------------------------------
    -1 -1 8.0.0.0.0
    0 0 create rollback segment system storage ( initial 112k next 1024k
    minextents 1 m
    8 8 create cluster c_file#_block#("ts#" number,"segfile#" number,
    "segblock#" number)
    9 9 create index i_file#_block# on cluster c_file#_block# pctfree 10
    initrans 2 maxt
    14 14 create table seg$("file#" number not null,"block#" number not
    null,"type#" numbe
    5 5 create table clu$("obj#" number not null,"dataobj#" number,"ts#"
    number not null
    6 6 create cluster c_ts#("ts#" number) pctfree 10 pctused 40 initrans
    2 maxtrans 255
    7 7 create index i_ts# on cluster c_ts# pctfree 10 initrans 2 maxtrans
    255 storage (
    ....

下 一 页
2页: 第 [1] [2]

责任编辑:gzu521

IT认证分类
计算机软件水平考试
全国计算机等级考试
思科认证
微软认证
ORACLE/CIW认证
Linux认证
JAVA认证
其它认证
分类推荐信息
更多...
大类最新文章
更多...