oracle initrans and maxtrans

SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
PL/SQL Release 9.2.0.1.0 - Production
CORE    9.2.0.1.0       Production
TNS for 32-bit Windows: Version 9.2.0.1.0 - Production
NLSRTL Version 9.2.0.1.0 - Production

SQL> create table testinit(id number)
2  initrans 1;

表已创建。

SQL> select table_name,ini_trans,max_trans from user_tables  where table_name='TESTINIT';

TABLE_NAME                      INI_TRANS  MAX_TRANS
------------------------------ ---------- ----------
TESTINIT                                1        255

SQL> drop table testinit;

表已删除。

SQL> create table testinit(id number)  initrans 3;

表已创建。

SQL> select table_name,ini_trans,max_trans from user_tables
2  where table_name='TESTINIT';

TABLE_NAME                      INI_TRANS  MAX_TRANS
------------------------------ ---------- ----------
TESTINIT                                3        255

SQL> create table testmax(id number)   maxtrans 100;

表已创建。

SQL> select table_name,ini_trans,max_trans from user_tables    where table_name='TESTMAX';

TABLE_NAME                      INI_TRANS  MAX_TRANS
------------------------------ ---------- ----------
TESTMAX                                 1        100

SQL> drop table testmax ;

表已删除。

SQL> create table testmax(id number)   maxtrans 256;
maxtrans 256
*
第 2 行出现错误:
ORA-02209: 无效的 MAXTRANS 选项值

####################################换11G#########

SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
PL/SQL Release 11.1.0.6.0 - Production
CORE    11.1.0.6.0      Production
TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
NLSRTL Version 11.1.0.6.0 - Production

SQL> create table testinit(id int)
2  initrans 1;

表已创建。

SQL> select table_name,ini_trans,max_trans from user_tables  where table_name='TESTINIT';

TABLE_NAME                      INI_TRANS  MAX_TRANS
------------------------------ ---------- ----------
TESTINIT                                1        255

SQL> drop table testinit purge;

表已删除。

SQL> create table testinit(id number)  initrans 3;

表已创建。

SQL> select table_name,ini_trans,max_trans from user_tables  where table_name='TESTINIT';

TABLE_NAME                      INI_TRANS  MAX_TRANS
------------------------------ ---------- ----------
TESTINIT                                3        255

SQL> create table testmax(id number)   maxtrans 100;

表已创建。

SQL> select table_name,ini_trans,max_trans from user_tables  where table_name='TESTINIT';

TABLE_NAME                      INI_TRANS  MAX_TRANS
------------------------------ ---------- ----------
TESTINIT                                3        255

SQL> drop table testmax purge;

表已删除。

SQL> create table testmax(id number)   maxtrans 256;
create table testmax(id number)   maxtrans 256
*
第 1 行出现错误:
ORA-02209: 无效的 MAXTRANS 选项值

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.

也就是说从Oracle10g开始,对于单个数据块,Oracle缺省最大支持255个并发,MAXTRANS参数被废弃,无论你是否指定,11G中initrans 默认为3,9i是默认为1,这也是oracle 一直在需要一个平衡点。

15 thoughts on “oracle initrans and maxtrans”

  1. 1个8K的块除去oracle管理用的空间,一般不会超过255行数据,如果一个事务只锁定一行,也不会超过255个事务。

Comments are closed.