Data Block是資料庫中最小的I/O單元,下面我來簡單介紹下資料區塊的基本結構。
OK!跟著我一步步實驗:
一、建資料表空間
SQL>create tablespace tp1 datafile '/oradata/bxocp/tp01.dbf' size 10M;
二、建使用者及授權
SQL>create user gyj identified by gyj default tablespace tp1;
SQL>grant dba to gyj;
三、建表
SQL>conn gyj/gyj
SQL>create table t1 (id int,name varchar2(100));
四、插入一行資料
SQL>insert into t1 values(1,'AAAAA');
SQL>commit;
五、手動發生一個檢查點,使上面一行資料寫到資料檔案
alter system checkpoint;
六、查這行資料所在的檔案號和塊號
SQL>col name for a10
SQL>select id,name,dbms_rowid.rowid_relative_fno(rowid) file#,dbms_rowid.rowid_block_number(rowid) block# from t1;
ID NAME FILE# BLOCK#
---------- --------- ---------- ----------
1 AAAAA 6 135
七、轉儲6號檔案135號塊,新開個視窗
[oracle@guoyj ~]$ sqlplus / as sysdba
SQL> alter system dump datafile 6 block 135;
八、找到轉儲的檔案
SQL> show parameter dump
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
background_core_dump string partial
background_dump_dest string /u01/app/oracle/diag/rdbms/bxo
cp/bxocp/trace
再開一新視窗
[oracle@guoyj ~]$ cd /u01/app/oracle/diag/rdbms/bxocp/bxocp/trace
[oracle@guoyj trace]$ ls -lFtr
下面這個追蹤記錄檔就是6號檔案135號塊轉儲出來的資料區塊資訊
-rw-r----- 1 oracle oinstall 3363 Dec 11 18:02 bxocp_ora_5429.trc -
九、分析資料塊結構
[oracle@guoyj trace]$ vi bxocp_ora_5429.trc
Trace file /u01/app/oracle/diag/rdbms/bxocp/bxocp/trace/bxocp_ora_5429.trc
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORACLE_HOME = /u01/app/oracle/product/11.2.0
System name: Linux
Node name: guoyj
Release: 2.6.18-128.el5
Version: #1 SMP Wed Dec 17 11:41:38 EST 2008
Machine: x86_64
VM name: VMWare Version: 6
Instance name: bxocp
Redo thread mounted by this instance: 1
Oracle process number: 28
Unix process pid: 5429, image: oracle@guoyj (TNS V1-V3)
*** 2012-12-11 18:02:31.307
*** SESSION ID:(29.15) 2012-12-11 18:02:31.307
*** CLIENT ID:() 2012-12-11 18:02:31.307
*** SERVICE NAME:(SYS$USERS) 2012-12-11 18:02:31.307
*** MODULE NAME:(sqlplus@guoyj (TNS V1-V3)) 2012-12-11 18:02:31.307
*** ACTION NAME:() 2012-12-11 18:02:31.307
Start dump data blocks tsn: 7 file#:6 minblk 135 maxblk 135