匯入資料時遇見ORA-00054

楊奇龍發表於2011-04-01
今天應開發人員要求對一個表進行匯入。發現如下錯誤:
ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired
ORA-00955: name is already used by an existing object
經過檢視鎖的使用情況,發現有開發人員對要匯入的表進行dml操作。
下面模擬一下環境:、
session 1:
yang@rac1>update t set b=1 where a=4;
1 row updated.
匯出資料:
oracle@rac1:rac1 /tmp/dump>impdp yang/yang directory=dumpdir  dumpfile=tm.dmp  tables=t  exclude=index
Import: Release 11.2.0.1.0 - Production on Fri Apr 1 23:41:48 2011
Data Mining and Real Application Testing options
Master table "YANG"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "YANG"."SYS_IMPORT_TABLE_01":  yang/******** directory=dumpdir dumpfile=tm.dmp tables=t exclude=index
Processing object type TABLE_EXPORT/TABLE/TABLE
ORA-39151: Table "YANG"."T" exists. All dependent metadata and data will be skipped due to table_exists_action of skip
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Job "YANG"."SYS_IMPORT_TABLE_01" completed with 1 error(s) at 23:42:51
使用  table_exists_action=skip (預設值)時,沒有報錯。但是使用 table_exists_action=replace 是 要先對錶進行drop,然後重建並匯入。此時報錯
oracle@rac1:rac1 /tmp/dump>impdp yang/yang directory=dumpdir  dumpfile=tm.dmp table_exists_action=replace  tables=t  exclude=index
Import: Release 11.2.0.1.0 - Production on Fri Apr 1 23:45:00 2011
Master table "YANG"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "YANG"."SYS_IMPORT_TABLE_01":  yang/******** directory=dumpdir dumpfile=tm.dmp table_exists_action=replace tables=t exclude=index
Processing object type TABLE_EXPORT/TABLE/TABLE
ORA-39121: Table "YANG"."T" can't be replaced, data will be skipped. Failing error is:
ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired
ORA-00955: name is already used by an existing object
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Job "YANG"."SYS_IMPORT_TABLE_01" completed with 1 error(s) at 23:46:01

檢視lock的使用情況:
yang@rac1>SELECT OBJECT_ID,OBJECT_NAME FROM DBA_OBJECTS WHERE OBJECT_NAME='T' AND WNER='YANG';
 OBJECT_ID OBJECT_NAME
---------- --------------------------------------------------------------------------------------------------------------------------------
    130763 T
yang@rac1>@lock
lock                         lock                                                      blocked
address           session id type         id1       id2 lock mode  req mode      BLOCK   sessid
---------------- ----------- ------ --------- --------- --------- --------- ---------- --------
000000018B9B18E8         959 XR             4         0         1         0    2
000000018B9B22A8         385 RT             1         2         6         0    2
00002B79A83626F0           5 TM        130763         0         3         0    2  ====》該表上有tm鎖
000000018B9B38C8        1344 AE           100         0         4         0    2
在對正在使用的資料庫進行匯入資料時(某個表)最後先確認是否正在使用。然後再匯入。當然每個案例都有所不同,仁者見仁智者見智了。
好了,睡覺。。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22664653/viewspace-691506/,如需轉載,請註明出處,否則將追究法律責任。

相關文章