9i和10g中的initrans,maxtrans参数

    下面我们讨论一下initrans参数,主要分为9i,10g两个版本下:noassm,assm几种情况:
1、Oracle 9i:
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
PL/SQL Release 9.2.0.4.0 - Production
CORE      9.2.0.3.0            Production
TNS for Linux: Version 9.2.0.4.0 - Production
NLSRTL Version 9.2.0.4.0 - Production
SQL> create tablespace noassm datafile'/data/oracle/oradata/test/noassm01.dbf' size 5m;
Tablespace created.
--- 在Oracle9i中,假如你不指定extent的管理方式,默认的是Local,这是因为用dbca建库时,默认的system表空间的管理方式是local的。 如果你在这种情况下想DMT类型的tablespace会报错:
SQL> create tablespace dmt datafile'/data/oracle/oradata/test/dmt01.dbf' size 5m
  2  extent managementdictionary;
create tablespace dmt datafile'/data/oracle/oradata/test/dmt01.dbf' size 5m
*
ERROR at line 1:
ORA-12913: Cannot create dictionary managedtablespace
SQL> create tablespace assm datafile'/data/oracle/oradata/test/assm01.dbf' size 5m
  2  segment space managementauto;
Tablespace created.
SQL> selecttablespace_name,EXTENT_MANAGEMENT , SEGMENT_SPACE_MANAGEMENT
  2  fromdba_tablespaces;
TABLESPACE_NAME               EXTENT_MAN SEGMEN
------------------------------ ---------- ------
SYSTEM                        LOCAL     MANUAL
TEMP                          LOCAL     MANUAL
TEST_RESET                    LOCAL     MANUAL
UNDO2                         LOCAL     MANUAL
NOASSM                        LOCAL     MANUAL
ASSM                          LOCAL     AUTO
SQL> createtable noassm (id number) initrans 1tablespace noassm;
Tablecreated.
SQL> createtable assm (id number) initrans 1tablespace assm;
Tablecreated.
SQL> selectini_trans,max_trans from dba_tables where table_name like'%ASSM%';
 INI_TRANS MAX_TRANS
---------- ----------
       
 1       255
        1       255
SQL> selectfile_id,block_id from dba_extents where segment_name like'%ASSM%';
  FILE_ID   BLOCK_ID
---------- ----------
        2         9
        5         9
SQL> alter system dump datafile 2 block 10;
Systemaltered.
SQL> altersystem dump datafile 5 block 12;
Systemaltered.
---extent管理方式不一样,所以datablock的位置也有不同。
---dump 文件中的主要信息:
---NOASSM:
buffer tsn: 5 rdba: 0x0080000a(2/10)
scn: 0x0000.40098452 seq: 0x01 flg: 0x02 tail: 0x84520601
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
Block header dump:  0x0080000a
  Object id on Block? Y
  seg/obj: 0x61ad  csc:0x00.4009844e  itc: 2  flg:O  typ: 1 - DATA
        fsl: 0  fnx: 0x0 ver: 0x01
 
  Itl                    Xid                                  Uba                Flag  Lck              Scn/Fsc
0x01    0x0014.027.0000000c  0x010000a7.0001.12  --U-      1  fsc 0x0000.40098452
0x02    0x0000.000.00000000  0x00000000.0000.00  ----      0  fsc 0x0000.00000000
 
---ASSM:
buffer tsn: 6rdba: 0x0140000c (5/12)
scn: 0x0000.40098452 seq: 0x01 flg: 0x02 tail: 0x84520601
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
Block header dump:  0x0140000c
 Object id on Block? Y
 seg/obj: 0x61ae  csc:0x00.40098450  itc: 2  flg:E  typ: 1 - DATA
    brn: 0  bdba: 0x1400009 ver: 0x01
    inc: 0  exflg: 0
 
 Itl          Xid                 Uba        Flag Lck       Scn/Fsc
0x01  0x0014.027.0000000c 0x010000a7.0001.13 --U-   1  fsc 0x0000.40098452
0x02  0x0000.000.00000000 0x00000000.0000.00 ----   0  fsc 0x0000.00000000
2、Oracle10g:
SQL> select *from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 -Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE   10.2.0.1.0     Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
SQL> createtablespace noassm datafile'/app/oracle/oradata/testdb/noassm01.dbf' size5m;
Tablespacecreated.
SQL> create tablespace assm datafile'/app/oracle/oradata/testdb/assm01.dbf' size 5m
  2 
segment space management auto;
Tablespacecreated.
SQL> selecttablespace_name,extent_management,segment_space_management
  2  from dba_tablespaces wheretablespace_name like '%ASSM%';
TABLESPACE_NAME               EXTENT_MAN SEGMEN
------------------------------ ---------- ------
NOASSM                        LOCAL     AUTO
ASSM                          LOCAL     AUTO
---10g默认创建的表空间就是ASSM了。
SQL> create table noassm (id number) initrans 1 tablespace noassm;
Table created.
SQL> create table assm (id number)initrans 1 tablespaceassm;
Table created.
SQL> insert into noassmvalues(1);
1 row created.
SQL> insert into assmvalues(1);
1 row created.
SQL> commit;
SQL> selecttable_name,ini_trans,max_trans
  2  from dba_tables wheretable_name in ('NOASSM','ASSM');
TABLE_NAME                     INI_TRANS  MAX_TRANS
------------------------------ ---------- ----------
NOASSM                                 1       255
ASSM                                   
1       255
SQL> selectdbms_rowid.rowid_relative_fno(rowid),dbms_rowid.rowid_block_number(rowid)
  2  from noassm;
DBMS_ROWID.ROWID_RELATIVE_FNO(ROWID)DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)
------------------------------------------------------------------------
                                  7                                  16
SQL> selectdbms_rowid.rowid_relative_fno(rowid),dbms_rowid.rowid_block_number(rowid)
  2  from assm;
DBMS_ROWID.ROWID_RELATIVE_FNO(ROWID)DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)
------------------------------------------------------------------------
                                  8                                  16
SQL> altersystem dump datafile 7 block 16;
Systemaltered.
SQL> altersystem dump datafile 8 block 16;
Systemaltered.
---dump 文件中的主要信息:
 Object id on Block? Y
 seg/obj: 0xd2b5  csc:0x00.119070  itc: 2  flg:E  typ: 1 - DATA
    brn: 0  bdba: 0x1c00009 ver: 0x01 opc: 0
    inc: 0  exflg: 0
 
 Itl          Xid                 Uba        Flag Lck       Scn/Fsc
0x01  0x0002.02a.00000293 0x00800b09.01e2.36 --U-   1  fsc 0x0000.00119081
0x02  0x0000.000.00000000 0x00000000.0000.00 ----   0  fsc 0x0000.00000000
 
 seg/obj: 0xd2b6  csc:0x00.119070  itc: 2  flg:E  typ: 1 - DATA
    brn: 0  bdba: 0x2000009 ver: 0x01 opc: 0
    inc: 0  exflg: 0
 
 Itl          Xid                 Uba        Flag Lck       Scn/Fsc
0x01  0x0002.02a.00000293 0x00800b09.01e2.37 --U-   1  fsc 0x0000.00119081
0x02  0x0000.000.00000000 0x00000000.0000.00 ----   0  fsc 0x0000.00000000
---结论1:
    可见,不论是NOASSM,还是ASSM从9i开始,默认的最小的initrans为2,虽然你创建表的时候可以指定为1,但是这个1是不会生效的,会被Oracle默认的设置屏蔽。
 
---继续,我们接下来就看看maxtrans这个参数,上面我们知道9i,10g默认的maxtrans都是255,那么这个参数据是否可以超越呢?
1、Oracle9i:
SQL> alter table noassm maxtrans254;           
Table altered.
SQL> alter table noassm maxtrans 256;
alter table noassm maxtrans 256
                                                      *
ERROR at line 1:
ORA-02209: invalid MAXTRANS optionvalue
2、Oracle10g:
SQL> alter table noassm maxtrans254;
Table altered.
SQL> altertable noassm maxtrans 256;
alter table noassm maxtrans 256
                           *
ERROR at line 1:
ORA-02209: invalid MAXTRANS optionvalue
---可见,这个最大的maxtrans是不可超越的,不论是9i还是10g。
---那么,还有个疑问,两个版本下maxtrans是否都生效了呢?
1、Oracle 9i:
SQL> select ini_trans,max_trans from dba_tables wheretable_name like '%ASSM%';
  INI_TRANS  MAX_TRANS
---------- ----------
                1              254
                1              255
2、Oracle 10g:
SQL> select table_name,ini_trans,max_trans from dba_tableswhere table_name like '%ASSM%';
TABLE_NAME                                          INI_TRANS  MAX_TRANS
------------------------------ ---------- ----------
WRH$_WAITCLASSMETRIC_HISTORY                      1              255
NOASSM                                                                  1              255
ASSM                                                                      1              255
---9i 生效了,但10g却没有生效。
---这是因为10gmaxtrans这个参数已经被废弃了,不管你怎么设置,总是255。
---结论2:
    对于maxtrans这个参数,10g已经已经将其废弃了,不管如何设置,都是255。
并且这个参数不管是9i还是10g,它的最大值都是255,这是因为 在Oracle内部是通过1个字节来记录这个参数的大小的。


查阅Oracle手册得到如下说明:

Note:In earlier releases of Oracle Database, the MAXTRANS parameter limited the number of transaction entries that could concurrently use data in a data block. This parameter has been deprecated.

Oracle Database now automatically allows up to 255 concurrent update transactions for any data block, depending on the available space in the block.
The database ignores MAXTRANS when specified by users only for new objects created when the COMPATIBLE initialization parameter is set to 10.0 or greater.


你可能感兴趣的:(9i和10g中的initrans,maxtrans参数)