DML_LOCKS设置为0导致SHUTDOWN IMMEDIATE失败

DML_LOCKS参数设置系统中允许DML锁的数量,如果将这个参数设置为0,会禁止ENQUEUE的产生,有可能轻微的提升系统的性能。
不过如果将这个参数设置为0,带来的后果会严重很多:

SQL> SHOW parameter dml_locks
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
dml_locks INTEGER 264
SQL> ALTER system SET dml_locks = 0 scope = spfile;
System altered.
SQL> shutdown immediate
DATABASE closed.
DATABASE dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 524288000 bytes
Fixed SIZE 2097560 bytes
Variable SIZE 150998632 bytes
DATABASE Buffers 369098752 bytes
Redo Buffers 2093056 bytes
DATABASE mounted.
DATABASE opened.
SQL> conn test/test
Connected.
SQL> CREATE TABLE t_dml (id NUMBER);
TABLE created.
SQL> INSERT INTO t_dml VALUES (1);
1 ROW created.
SQL> UPDATE t_dml SET id = 2;
1 ROW updated.
SQL> DELETE t_dml;
1 ROW deleted.
SQL> commit;
Commit complete.
SQL> CREATE INDEX i_t_dml_id ON t_dml(id);
CREATE INDEX i_t_dml_id ON t_dml(id)
*
ERROR at line 1:
ORA-00062: DML full-TABLE LOCK cannot be acquired; DML_LOCKS IS 0
 
SQL> TRUNCATE TABLE t_dml;
TRUNCATE TABLE t_dml
*
ERROR at line 1:
ORA-00062: DML full-TABLE LOCK cannot be acquired; DML_LOCKS IS 0
 
SQL> DROP TABLE t_dml purge;
DROP TABLE t_dml purge
*
ERROR at line 1:
ORA-00062: DML full-TABLE LOCK cannot be acquired; DML_LOCKS IS 0

可以看到,并非是DML_LOCKS设置为0,就不能执行DML操作了,事实上DML仍然可以执行。相反由于大部分的DDL在执行过程中需要对表加锁,因此大部分DDL语句在DML_LOCKS设置为0后不能在运行了。
收影响的操作不只是DDL而已,连SHUTDOWN IMMEDIATE都不能幸免:

SQL> conn / AS sysdba
Connected.
SQL> shutdown immediate
ORA-00062: DML full-TABLE LOCK cannot be acquired; DML_LOCKS IS 0
SQL> shutdown abort
ORACLE instance shut down.

也就是说设置DML_LOCKS后,只能使用ABORT方式关闭数据库了。

This entry was posted in ORACLE and tagged , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *