LoginSignup
1
0

More than 5 years have passed since last update.

TRUNCATE TABLE …等 の DDL で「ORA-54: リソース・ビジー…(ORA-00054: resource busy...)」が発生する際の小技(Oracle Database)

Posted at

以下のように TRUNCATE TABLE …文 や ALTER TABLE …文 を実行すると、
ORA-54エラー(リソース・ビジー) が 発生することがあります。
#十中八九トランザクションが走ってるケースやね彡(゚)(゚)

SQL> TRUNCATE TABLE TBL_A;
TRUNCATE TABLE TBL_A
               *
ERROR at line 1:
ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired


SQL> ALTER TABLE TBL_A DROP (C2);
ALTER TABLE TBL_A DROP (C2)
            *
ERROR at line 1:
ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired

そう云う場合は DDL_LOCK_TIMEOUTパラメータ を セッション単位で
変更して DDL を実行すると、パラメータの秒数分待機してくれるやで彡(゚)(゚)

ALTER SESSION SET DDL_LOCK_TIMEOUT = 1000000;

Session altered.

※待たされる。
TRUNCATE TABLE TBL_A;

トランザクションが完了すると、待機していたDDL文が実行されます。

TRUNCATE文の続き
Table truncated.

マニュアルも見とくやで彡(^)(^)

Oracle Databaseリファレンス 12cリリース2 (12.2) E72905-02
DDL_LOCK_TIMEOUT
http://docs.oracle.com/cd/E82638_01/REFRN/DDL_LOCK_TIMEOUT.htm#GUID-72D43EF8-F7AF-4011-8D64-73ABC4FB2154

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0