Oracle11gDDL wait option (DDL_LOCK_TIMEOUT)

Source: Internet
Author: User
DDL commands require the internal structure of the exclusive lock. If these locks are not available, an rdquo; ORA-00054: resourcebusyrdquo; will be returned when attempting to modify frequently accessed objects

DDL commands require the internal structure of the exclusive lock. If these locks are not available, an rdquo; ORA-00054: resource busyrdquo; will be returned when attempting to modify frequently accessed objects

DDL commands require the internal structure of the exclusive lock. If these locks are not available, a "ORA-00054: resource busy" will be returned, which can be particularly frustrating when attempting to modify frequently accessed objects, to solve this problem, Oracle 11g contains the DDL_LOCK_TIMEOUT parameter. You can use the alter system and alter session commands at the instance or session level.

DDL_LOCK_TIMEOUT indicates the number of seconds for a DDL command to wait for the lock to be available before the "resource busy" error is thrown. The default value is 0 (NOWAIT ).

SQL> create table ddl_lock_test (

Id number

);

SQL> insert into ddl_lock_test values (1 );



----------- Create a test table and insert a piece of data without commit;

----------- Create a new session, set DDL_LOCK_TIMEOUT to a non-zero value at the session level, and try to add a column to the table;





SQL> alter session set ddl_lock_timeout = 20;



SQL> alter table ddl_lock_test add (

Name varchar2 (20)

);



-------- This session will wait 20 seconds before the failure.

Alter table ddl_lock_test add (name varchar2 (20 ))

*

ERROR at line 1:

ORA-00054: resource busy and acquire with NOWAIT specified



---- If we repeat the alter table command and insert the first session of commit within 20 seconds, alter table will return a message indicating successful execution.



SQL> alter table ddl_lock_test add (

Name varchar2 (20)

);

Table altered.



SQL>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.