明明白白使用数据块:数据块格式深入解析

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




转载请注明:http://www.xcqg58.com/pxxx/pxxx/24.html