关于_NEXT_OBJECT

| No Comments | No TrackBacks

其实很多朋友都知道_NEXT_OBJECT是怎么回事,但这里我还是说一说吧,已经很清楚_NEXT_OBJECT的作用的朋友可以不用看剩下的内容了。

 

bootstrap$里并没有obj#=1的记录,如下所示:

SQL> select * from bootstrap$ where obj#=1;

 

     LINE#       OBJ# SQL_TEXT

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

 

这是因为在oracleobj#1object有特殊的作用,我们来看一下obj#=1object是什么:

SQL> select obj#,name,type#,dbms_rowid.rowid_relative_fno(rowid)||'_'||dbms_rowid.rowid_block_number(rowid) location from obj$ t where obj#=1;

 

      OBJ# NAME                                TYPE# LOCATION

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

         1 _NEXT_OBJECT                            0 1_122

 

可以看到oracleobj#=1object_NEXT_OBJECT,这条记录现在的位置是在file 1block 122。注意这里其TYPE#0,关于obj$type#的定义可以从sql.bsq中获取详细的信息,如下所示:

type#         number not null,                 /* object type (see KQD.H): */

  /* 1 = INDEX, 2 = TABLE, 3 = CLUSTER, 4 = VIEW, 5 = SYNONYM, 6 = SEQUENCE, */

             /* 7 = PROCEDURE, 8 = FUNCTION, 9 = PACKAGE, 10 = NON-EXISTENT, */

              /* 11 = PACKAGE BODY, 12 = TRIGGER, 13 = TYPE, 14 = TYPE BODY, */

      /* 19 = TABLE PARTITION, 20 = INDEX PARTITION, 21 = LOB, 22 = LIBRARY, */

                                             /* 23 = DIRECTORY , 24 = QUEUE, */

    /* 25 = IOT, 26 = REPLICATION OBJECT GROUP, 27 = REPLICATION PROPAGATOR, */

    /* 28 = JAVA SOURCE, 29 = JAVA CLASS, 30 = JAVA RESOURCE, 31 = JAVA JAR, */

                 /* 32 = INDEXTYPE, 33 = OPERATOR , 34 = TABLE SUBPARTITION, */

                                                  /* 35 = INDEX SUBPARTITION */

                                                    /* 57 = SECURITY PROFILE */

可以看到sql.bsq中对obj$type#说明里唯独没有type#0的情况。

 

那么_NEXT_OBJECT到底是什么呢?

311922.1中提到:

SYS._NEXT_OBJECT is an internal mechanism to generate the next OBJECT_ID or DATA_OBJECT_ID value when a new object is created in the database or you truncate an exisitng table. Oracle needs to lock this object, which is actually a sequence generator to get the value and use it. Waits on the _NEXT_OBJECT is expected as your application is doing repeatedly truncates and creates of database tables.

 

说的是再清晰不过了,我们现在来验证一下:

SQL> create table t1 as select * from dba_users;

 

Table created

 

SQL> alter system checkpoint;

 

System altered

 

SQL> select dump('_NEXT_OBJECT',16) from dual;

 

DUMP('_NEXT_OBJECT',16)

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

Typ=96 Len=12: 5f,4e,45,58,54,5f,4f,42,4a,45,43,54

 

BBED> set file 1

        FILE#           1

 

BBED> set block 122

        BLOCK#          122

 

BBED> dump

 File: /dras11/oradata/astca/system01.dbf (1)

 Block: 122              Offsets:    0 to  511           Dba:0x0040007a

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

 06020000 0040007a aa05a584 00080106 b4720000 01000000 00000012 aa05a583

 00080000 00010200 00000000 0005001e 0001b684 0080004f 475c4500 20010000

 aa05a584 0001006c ffff00ea 0110035c 035c0000 006c1f7c 1f3c1efb 1ebe1e7e

 01101dec 1da41d64 1d221ce1 1ca41c5c 1c1b1bda 1b9f1b5f 1b1f1adf 1aa21a54

 1a1719db 199a1959 191218d1 1890184f 180e17cd 178d174c 170c16cf 168f1653

 161415d8 15981559 151d14d5 1499145a 141913d9 139d1361 131e12dd 129d1260

 122411e3 11a21163 112010dd 10a11065 10280fe5 0fa40f5f 0f1a0ede 0e9c0e56

 0e150dd6 0d960d55 0d150cd5 0c990c5b 0c1a0bd4 0b840b34 0af40ab1 0a750a39

 09f409af 096a0925 08e508a5 08650825 07e507a4 07610722 06e606a9 061f05df

 05a10559 051604cd 048b0449 04030000 00000000 00000000 00000000 00000000

 00000000 00000000 00000000 00000000 00000000 2c011102 c10204c3 093e3b01

 800c5f4e 4558545f 4f424a45 435402c1 02ff0180 07786a06 13042b28 07786d06

 03130a3c 07786a06 13042b28 0180ffff 0180ff01 8004c307 38242c00 1102c102

 03c26463 01800c5f 4e455854 5f4f424a 45435402 c102ff01 8007786a 0613042b

 2807786a 06130432 1207786a 0613042b 280180ff ff0180ff 018004c3 0738242c

 001102c1 0202c207 01800c5f 4e455854 5f4f424a 45435402 c102ff01 8007786a

 

 <32 bytes per line>

 

BBED> set offset 340

        OFFSET          340

 

BBED> dump

 File: /dras11/oradata/astca/system01.dbf (1)

 Block: 122              Offsets:  340 to  851           Dba:0x0040007a

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

 2c011102 c10204c3 093e3b01 800c5f4e 4558545f 4f424a45 435402c1 02ff0180

 07786a06 13042b28 07786d06 03130a3c 07786a06 13042b28 0180ffff 0180ff01

 8004c307 38242c00 1102c102 03c26463 01800c5f 4e455854 5f4f424a 45435402

 c102ff01 8007786a 0613042b 2807786a 06130432 1207786a 0613042b 280180ff

 ff0180ff 018004c3 0738242c 001102c1 0202c207 01800c5f 4e455854 5f4f424a

 45435402 c102ff01 8007786a 0613042b 2807786a 0613042b 3507786a 0613042b

 280180ff ff0180ff 018004c3 0738242c 001102c1 0203c206 6401800c 5f4e4558

 545f4f42 4a454354 02c102ff 01800778 6a061304 2b280778 6a061304 2b350778

 6a061304 2b280180 ffff0180 ff018004 c3073824 2c001102 c10202c2 0601800c

 5f4e4558 545f4f42 4a454354 02c102ff 01800778 6a061304 2b280778 6a061304

 2b340778 6a061304 2b280180 ffff0180 ff018004 c3073824 2c001102 c10203c2

 05640180 0c5f4e45 58545f4f 424a4543 5402c102 ff018007 786a0613 042b2807

 786a0613 042b3407 786a0613 042b2801 80ffff01 80ff0180 04c30738 242c0011

 02c10202 c2050180 0c5f4e45 58545f4f 424a4543 5402c102 ff018007 786a0613

 042b2807 786a0613 042b2d07 786a0613 042b2801 80ffff01 80ff0180 04c30738

 242c0011 02c10203 c2046401 800c5f4e 4558545f 4f424a45 435402c1 02ff0180

 

 <32 bytes per line>

dump出来的结果我们可以看到:现在在_NEXT_OBJECTITL上的LCK01,其对应的XID0005001e 0001b684,我们接着来看一下undo$

SQL> select file#,block# from undo$ where us#=5;

 

     FILE#     BLOCK#

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

         2         73

 

我们dump一下上述block,如下是dump出来的内容:

Start dump data blocks tsn: 1 file#: 2 minblk 73 maxblk 73

buffer tsn: 1 rdba: 0x00800049 (2/73)

scn: 0x0008.aa05a703 seq: 0x01 flg: 0x00 tail: 0xa7032601

frmt: 0x02 chkval: 0x0000 type: 0x26=KTU SMU HEADER BLOCK

  Extent Control Header

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

  Extent Header:: spare1: 0      spare2: 0      #extents: 2      #blocks: 15   

                  last map  0x00000000  #maps: 0      offset: 4080 

      Highwater::  0x0080004f  ext#: 0      blk#: 5      ext size: 7    

  #blocks in seg. hdr's freelists: 0    

  #blocks below: 0    

  mapblk  0x00000000  offset: 0    

                   Unlocked

     Map Header:: next  0x00000000  #extents: 2    obj#: 0      flag: 0x40000000

  Extent Map

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

   0x0080004a  length: 7    

   0x12c00011  length: 8    

 

 Retention Table

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

 Extent Number:0  Commit Time: 1243855490

 Extent Number:1  Commit Time: 1244001080

 

  TRN CTL:: seq: 0x475c chd: 0x0028 ctl: 0x0025 inc: 0x00000000 nfb: 0x0001

            mgc: 0x8201 xts: 0x0068 flg: 0x0001 opt: 2147483646 (0x7ffffffe)

            uba: 0x0080004f.475c.47 scn: 0x0008.aa05782a

Version: 0x01

  FREE BLOCK POOL::

    uba: 0x0080004f.475c.47 ext: 0x0  spc: 0x418  

    uba: 0x00000000.4725.04 ext: 0x10 spc: 0x1e1a 

    uba: 0x00000000.4690.07 ext: 0x0  spc: 0x1ce8 

    uba: 0x00000000.45c4.01 ext: 0x2  spc: 0x1fa0 

    uba: 0x00000000.3ab4.01 ext: 0x2  spc: 0x1fa0 

  TRN TBL::

 

  index  state cflags  wrap#    uel         scn            dba            parent-xid    nub     stmt_num

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

   0x00    9    0x00  0x1b72b  0x0010  0x0008.aa059391  0x0080004a  0x0000.000.00000000  0x00000001   0x00000000

  ......省略显示部分内容

   0x1e    9    0x00  0x1b684  0x0004  0x0008.aa05a584  0x0080004f  0x0000.000.00000000  0x00000001   0x00000000

   ......省略显示部分内容

   0x2f    9    0x00  0x1b777  0x0007  0x0008.aa05a104  0x0080004a  0x0000.000.00000000  0x00000001   0x00000000

End dump data blocks tsn: 1 file#: 2 minblk 73 maxblk 73

 

我们从dump出来的结果可以看到XID0005001e 0001b684所对应的那条在transaction table中的记录的state99表示Inactiveno local transaction,即obj$_NEXT_OBJECT这条记录实际上是已经commit了,只不过其行头的ITL没有被清掉,从我后续的测试来看,不管我怎样操作,只要我没碰122这个block,那oracle这里根本就不会清掉_NEXT_OBJECT所对应记录行头上的ITL

 

我们这里继续,现在我们来看一个能清掉行头ITL的例子:

继续来看一下我们之前建的表T1

SQL> select obj#,name,type#,dbms_rowid.rowid_relative_fno(rowid)||'_'||dbms_rowid.rowid_block_number(rowid) location from obj$ where name='T1';

 

      OBJ# NAME                                TYPE# LOCATION

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

     86148 T1                                      2 1_55579

 

SQL> select dump('T1',16) from dual;

 

DUMP('T1',16)

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

Typ=96 Len=2: 54,31

 

BBED> set file 1

        FILE#           1

 

BBED> set block 55579

        BLOCK#          55579

 

BBED> dump

 File: /dras11/oradata/astca/system01.dbf (1)

 Block: 55579            Offsets:    0 to  511           Dba:0x0040d91b

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

 06020000 0040d91b aa05a598 00080106 5bc20000 01030025 00000012 aa05a585

 00080000 1f010300 0040d91c 000a001a 0000b8d4 0080009b 2c713b00 20010000

 aa05a598 0001004c ffff00aa 04f30957 09570000 004c1f67 1f161ed1 1e821e31

 1de21d93 1d3b1cf6 1cac1c68 1c231bde 1b991b54 1b0a1ac5 1a7e1a34 19ea19a3

 19591912 18c81878 182c17e4 1799174d 16fc16b9 1672162d 15e915a4 1560151c

 14d2148b 144213fc 13b6136d 131e0618 12931250 120411c0 117c1138 10f410a3

 10541000 0fb10f62 0f0e0ec8 0e820e3c 0df60db2 0d6d0585 0ccc0c71 0c2d0be7

 0ba209c9 09880944 04f30532 0a0b1104 c3093c49 04c3093c 4902c140 09504b5f

 50455253 4f4e02c1 05ff02c1 0207786c 06140b19 2507786c 06140b19 2507786c

 06140b19 25022c00 1104c309 3e05ff02 c1410a50 5f534155 544f4443 4d02c102

 ff02c10b 07786d03 0912383a 07786d03 0912383a 0793700c 1f183c3c 02c102ff

 ff0180ff 02c10704 c3073824 2c001104 c3093d51 04c3093e 0302c150 0a55504c

 50445454 45535402 c1021155 50445445 53545f50 4152545f 30373036 02c11407

 786d0303 0e0f3407 786d0309 0f2f3807 786d0303 0e0f3402 c102ffff 0180ff02

 c10704c3 0738242c 001104c3 093d5103 c3093e02 c1500a55 504c5044 54544553

 5402c102 11555044 54455354 5f504152 545f3037 303602c1 1407786d 03030e0f

 

 <32 bytes per line>

 

BBED> set offset 1335

        OFFSET          1335

 

BBED> dump

 File: /dras11/oradata/astca/system01.dbf (1)

 Block: 55579            Offsets: 1335 to 1846           Dba:0x0040d91b

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

 2c011104 c3093e31 04c3093e 31018002 543102c1 02ff02c1 0307786d 0603130a

 3c07786d 0603130a 3c07786d 0603130a 3c02c102 ffff0180 ff02c107 02c1022c

 001104c3 093e2b04 c3093e2b 02c14113 4944585f 54455354 44524f50 325f4f42

 4a494402 c105ff02 c1020778 6d050512 1b050778 6d050512 1b050778 6d050512

 1b0502c1 02ffff01 80ff02c1 0704c307 38242c00 1104c309 3e2a04c3 093e2a02

 c1410954 45535444 524f5032 02c102ff 02c10307 786d041c 10261a07 786d0505

 121b0607 786d041c 10261a02 c102ffff 0180ff02 c10702c1 023c0111 04c3093e

 2904c309 3e2902c1 410e4f44 555f3030 30303038 36313334 02c102ff 02c10307

 786d041c 10222607 786d041c 10222607 786d041c 10222602 c102ffff 0180ff02

 c10702c1 022c0011 04c3093e 2804c309 3e2802c1 41095445 53544452 4f503102

 c102ff02 c1030778 6d041c10 1c240778 6d041c10 1c240778 6d041c10 1c2402c1

 02ffff01 80ff02c1 0702c102 3c011104 c3093e27 04c3093e 2702c141 0e4f4455

 5f303030 30303836 31333302 c102ff02 c1030778 6d041c10 140b0778 6d041c10

 1d1d0778 6d041c10 1d1d02c1 02ffff01 80ff02c1 0702c103 3c011104 c3093e23

 04c3093e 2302c141 09544553 5444524f 503202c1 02ff02c1 0307786d 041c0f0b

 1407786d 041c0f0b 1407786d 041c0f0b 1402c102 ffff0180 ff02c107 02c1023c

 

 <32 bytes per line>

dump结果里我们可以看到现在obj$T1这条记录的行头的ITL01,现在我们让这个01消失:

SQL> create table t2 as select * from dba_users;

 

Table created

 

SQL> alter system checkpoint;

 

System altered

 

SQL> select obj#,name,type#,dbms_rowid.rowid_relative_fno(rowid)||'_'||dbms_rowid.rowid_block_number(rowid) location from obj$ where name='T2';

 

      OBJ# NAME                                TYPE# LOCATION

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

      86149 T2                                      2 1_55579

 

退出BBED后再次进入:

$ bbed parfile=par.txt

Password:

 

BBED: Release 2.0.0.0.0 - Limited Production on Wed Jun 3 20:04:32 2009

 

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

 

************* !!! For Oracle Internal Use only !!! ***************

 

BBED> set file 1

        FILE#           1

 

BBED> set block 55579

        BLOCK#          55579

 

BBED> set offset 1335

        OFFSET          1335

 

BBED> dump

 File: /dras11/oradata/astca/system01.dbf (1)

 Block: 55579            Offsets: 1335 to 1846           Dba:0x0040d91b

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

 2c001104 c3093e31 04c3093e 31018002 543102c1 02ff02c1 0307786d 0603130a

 3c07786d 0603130a 3c07786d 0603130a 3c02c102 ffff0180 ff02c107 02c1022c

 001104c3 093e2b04 c3093e2b 02c14113 4944585f 54455354 44524f50 325f4f42

 4a494402 c105ff02 c1020778 6d050512 1b050778 6d050512 1b050778 6d050512

 1b0502c1 02ffff01 80ff02c1 0704c307 38242c00 1104c309 3e2a04c3 093e2a02

 c1410954 45535444 524f5032 02c102ff 02c10307 786d041c 10261a07 786d0505

 121b0607 786d041c 10261a02 c102ffff 0180ff02 c10702c1 023c0111 04c3093e

 2904c309 3e2902c1 410e4f44 555f3030 30303038 36313334 02c102ff 02c10307

 786d041c 10222607 786d041c 10222607 786d041c 10222602 c102ffff 0180ff02

 c10702c1 022c0011 04c3093e 2804c309 3e2802c1 41095445 53544452 4f503102

 c102ff02 c1030778 6d041c10 1c240778 6d041c10 1c240778 6d041c10 1c2402c1

 02ffff01 80ff02c1 0702c102 3c011104 c3093e27 04c3093e 2702c141 0e4f4455

 5f303030 30303836 31333302 c102ff02 c1030778 6d041c10 140b0778 6d041c10

 1d1d0778 6d041c10 1d1d02c1 02ffff01 80ff02c1 0702c103 3c011104 c3093e23

 04c3093e 2302c141 09544553 5444524f 503202c1 02ff02c1 0307786d 041c0f0b

 1407786d 041c0f0b 1407786d 041c0f0b 1402c102 ffff0180 ff02c107 02c1023c

 

 <32 bytes per line>

 

可以看到,我这里已经成功让obj$T1这条记录的行头的ITL01变成了00,这里的本质原因是因为55579这个blockITC只有1

 

呵呵,说了一大堆没什么用的东西,现在来说一点有用的,很多朋友都知道obj#小于56的那些objectoracle中的核心bootstrap对象,其实还有一些非核心的bootstrap对象也需要我们注意,301416.1中对这些非核心的bootstrap对象有所描述:

Objects with data_object_id less than 56 are classified as core bootstrap objects.

The objects are added to the bootstrap. The objects affected are:

hist_head$

histgrm$

i_hh_obj#_col#

i_hh_obj#_intcol#

i_obj#_intcol#

i_h_obj#_col#

c_obj#_intcol#

 

From 10.1 the following objects have been added:

fixed_obj$

tab_stats$

ind_stats$

i_fixed_obj$_obj#

i_tab_stats$_obj#

i_ind_stats$_obj#

object_usage

 

These additional objects shall be re-classified (or) ignored by following methods.

1. Opening the database in migrate mode

2. Using event 38003

No TrackBacks

TrackBack URL: http://dbsnake.com/cgi-bin/mt/mt-tb.cgi/40

Leave a comment