日期:2014-05-16 浏览次数:20384 次
环境:
00:24:16 sys@ORCL (^ω^) select * from v$version where rownum=1; BANNER -------------------------------------------- Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
我们要查询自己系统的一个表,则首先是去数据字典中找到该表的结构性信息。这些结构性信息存储在数据字典表中,但我们又从哪里获得数据字典表本身的结构性信息呢?虽然从表中我们可以查询到字典表本身的结构性信息,那在数据库open的时候最初是如何确定结构的?是写死在程序中呢?还是怎样处理的?oracle是怎么找到系统表空间的物理上的数据的?
23:48:02 sys@ORCL (^ω^) shutdown immediate 数据库已经关闭。 已经卸载数据库。 ORACLE 例程已经关闭。 23:48:54 sys@ORCL (^ω^) startup mount ORACLE 例程已经启动。 Total System Global Area 612368384 bytes Fixed Size 1250428 bytes Variable Size 192940932 bytes Database Buffers 411041792 bytes Redo Buffers 7135232 bytes 数据库装载完毕。 23:49:20 sys@ORCL (^ω^) alter session set sql_trace=true; 会话已更改。 23:49:44 sys@ORCL (^ω^) alter database open; 数据库已更改。
trc文件如下:
===================== PARSING IN CURSOR #1 len=19 dep=0 uid=0 oct=35 lid=0 tim=18716803687 hv=1907384048 ad='33ecf028' alter database open END OF STMT PARSE #1:c=0,e=1749,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=1,tim=18716803683 =====================
第一个对象的创建:
PARSING IN CURSOR #2 len=188 dep=1 uid=0 oct=1 lid=0 tim=18717747631 hv=1365064427 ad='33ec080c' create table bootstrap$ ( line# number not null, obj# number not null, sql_text varchar2(4000) not null) storage (initial 50K objno 56 extents (file 1 block 377)) END OF STMT PARSE #2:c=0,e=549,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=4,tim=18717747628 EXEC #2:c=0,e=195,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=4,tim=18717750171 =====================
逐步提取内容,来建立数据字典表本身的结构
PARSING IN CURSOR #2 len=55 dep=1 uid=0 oct=3 lid=0 tim=18717751282 hv=2111436465 ad='33ec0098' select line#, sql_text from bootstrap$ where obj# != :1 END OF STMT PARSE #2:c=0,e=538,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=4,tim=18717751278 EXEC #2:c=0,e=35732,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=4,tim=18717789730 FETCH #2:c=0,e=1528,p=4,cr=3,cu=0,mis=0,r=1,dep=1,og=4,tim=18717792281 FETCH #2:c=0,e=43,p=0,cr=1,cu=0,mis=0,r=1,dep=1,og=4,tim=18717793026 FETCH #2:c=0,e=34,p=0,cr=1,cu=0,mis=0,r=1,dep=1,og=4,tim=18717793574 ..................................
先对bootstrap$做些观察:
00:05:00 sys@ORCL (^ω^) desc bootstrap$ 名称 是否为空? 类型 ----------------------------------------- -------- ---------------------------- LINE# NOT NULL NUMBER OBJ# NOT NULL NUMBER SQL_TEXT NOT NULL VARCHAR2(4000) 00:05:42 sys@ORCL (^ω^) select count(1) from bootstrap$; COUNT(1) ---------- 57 00:05:55 sys@ORCL (^ω^) select obj#,sql_text from bootstrap$ where rownum<11; OBJ# ---------- SQL_TEXT -------------------------------------------- -1 8.0.0.0.0 0 CREATE ROLLBACK SEGMENT SYSTEM STORAGE ( INITIAL 112K NEXT 1024K MINEXTENTS 1 M AXEXTENTS 32765 OBJNO 0 EXTENTS (FILE 1 BLOCK 9)) 20 CREATE TABLE ICOL$("OBJ#" NUMBER NOT NULL,"BO#" NUMBER NOT NULL,"COL#" NUMBER NO OBJ# ---------- SQL_TEXT -------------------------------------------- T NULL,"POS#" NUMBER NOT NULL,"SEGCOL#" NUMBER NOT NULL,"SEGCOLLENGTH" NUMBER NO T NULL,"OFFSET" NUMBER NOT NULL,"INTCOL#" NUMBER NOT NULL,"SPARE1" NUMBER,"SPARE 2" NUMBER,"SPARE3" NUMBER,"SPARE