oracle 由於impdp 引起的表統計資訊被鎖 ORA-20005: object statistics are locked
發現一個使用者下統計資訊沒有生成,
查詢user_tab_modifications 發現變動資訊也超過10%
沒有警告日誌
執行
exec dbms_stats.gather_schema_stats(ownname => 'test',granularity => 'ALL',cascade => true);
還是沒有生成
然後執行報
begin dbms_stats.gather_table_stats(ownname => 'test',tabname => 'TCCLICOMH',granularity => 'ALL',cascade => true); end;
ORA-20005: object statistics are locked (stattype = ALL)
ORA-06512: 在 "SYS.DBMS_STATS", line 13056
ORA-06512: 在 "SYS.DBMS_STATS", line 13076
ORA-06512: 在 line 2
執行以下指令碼後正常
SQL> exec dbms_stats.unlock_schema_stats(ownname => 'test');
PL/SQL procedure successfully completed
SQL>exec dbms_stats.gather_schema_stats(ownname => 'test',granularity => 'ALL',cascade => true);
PL/SQL procedure successfully completed
原因是因為使用impdp 只匯入metadata_only 或(expdp的時候使用了contend=metadata_only)時 沒有使用 use exclude=(table_statistics,index_statistics)
引起的
參考文件
Symptoms
---------
Either of the following two error messages are signaled:
1. ORA-38029: object statistics are locked
2. ORA-20005: object statistics are locked (stattype = ALL)
Cause
---------
Possible Cause 1:
DBMS_STATS.LOCK_[SCHEMA|TABLE]_STATS has been used to lock statistics on the table.
Possible Cause 2:
Using import (imp) or data pump import (impdp) to import a table without data results in the table's statistics being locked in 10gR2.
Possible Cause 3:
After an IMPORT is finished for which ROWS=N, the statistics for all tables imported will be locked.
Part Number B14233-04 Database Readme 10g Release 2 (10.2) (39.5 Original Export/Import)
Possible Cause 4: If the table is a queue table then the statistics are intended to be empty and locked so that dynamic sampling will be used due to the table's volatility. During an upgrade to 10gR2 statistics on queue tables are deleted and then locked. In 10gR2 when a queue table is created statistics are locked while still empty.
Solution
---------
If the table is a queue table then the statistics should remain empty and locked so that dynamic sampling is used due to the volatility of queue tables. If the table is not a queue table, unlock the statistics using DBMS_STATS.UNLOCK_[SCHEMA|TABLE]_STATS or gather statistics on the table using DBMS_STATS.GATHER_[SCHEMA|TABLE|INDEX]_STATS and the force=>true parameter.
To prevent import (imp) from locking the table's statistics when importing a table without therows (rows=n), use statistics=none. To prevent data pump import (impdp) from locking the table's statistics when importing a table without the rows (content=metadata_only), use exclude=(table_statistics,index_statistics).
查詢user_tab_modifications 發現變動資訊也超過10%
沒有警告日誌
執行
exec dbms_stats.gather_schema_stats(ownname => 'test',granularity => 'ALL',cascade => true);
還是沒有生成
然後執行報
begin dbms_stats.gather_table_stats(ownname => 'test',tabname => 'TCCLICOMH',granularity => 'ALL',cascade => true); end;
ORA-20005: object statistics are locked (stattype = ALL)
ORA-06512: 在 "SYS.DBMS_STATS", line 13056
ORA-06512: 在 "SYS.DBMS_STATS", line 13076
ORA-06512: 在 line 2
執行以下指令碼後正常
SQL> exec dbms_stats.unlock_schema_stats(ownname => 'test');
PL/SQL procedure successfully completed
SQL>exec dbms_stats.gather_schema_stats(ownname => 'test',granularity => 'ALL',cascade => true);
PL/SQL procedure successfully completed
原因是因為使用impdp 只匯入metadata_only 或(expdp的時候使用了contend=metadata_only)時 沒有使用 use exclude=(table_statistics,index_statistics)
引起的
參考文件
Symptoms
---------
Either of the following two error messages are signaled:
1. ORA-38029: object statistics are locked
2. ORA-20005: object statistics are locked (stattype = ALL)
Cause
---------
Possible Cause 1:
DBMS_STATS.LOCK_[SCHEMA|TABLE]_STATS has been used to lock statistics on the table.
Possible Cause 2:
Using import (imp) or data pump import (impdp) to import a table without data results in the table's statistics being locked in 10gR2.
Possible Cause 3:
After an IMPORT is finished for which ROWS=N, the statistics for all tables imported will be locked.
Part Number B14233-04 Database Readme 10g Release 2 (10.2) (39.5 Original Export/Import)
Possible Cause 4: If the table is a queue table then the statistics are intended to be empty and locked so that dynamic sampling will be used due to the table's volatility. During an upgrade to 10gR2 statistics on queue tables are deleted and then locked. In 10gR2 when a queue table is created statistics are locked while still empty.
Solution
---------
If the table is a queue table then the statistics should remain empty and locked so that dynamic sampling is used due to the volatility of queue tables. If the table is not a queue table, unlock the statistics using DBMS_STATS.UNLOCK_[SCHEMA|TABLE]_STATS or gather statistics on the table using DBMS_STATS.GATHER_[SCHEMA|TABLE|INDEX]_STATS and the force=>true parameter.
To prevent import (imp) from locking the table's statistics when importing a table without therows (rows=n), use statistics=none. To prevent data pump import (impdp) from locking the table's statistics when importing a table without the rows (content=metadata_only), use exclude=(table_statistics,index_statistics).
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15747463/viewspace-741040/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle 由於impdp 引起的表統計資訊被鎖 ORA-20005: object statistics are lockedOracleObject
- ORA-20005: object statistics are lockedObject
- IMP ORA-20005: object statistics are locked(一)Object
- IMP ORA-20005: object statistics are locked(二)Object
- ORA-20005:object statistics are locked (stattype = ALL)Object
- ORA-20005: object statistics are locked (stattype = ALL)Object
- 【STAT】Oracle 表統計資訊被鎖,如何建立索引Oracle索引
- ORA-38029: object statistics are lockedObject
- oracle鎖表問題處理 v$lock v$locked_objectOracleObject
- [轉] oracle統計資訊(statistics)和直方圖(histogram)Oracle直方圖Histogram
- oracle檢視被鎖的表和解鎖Oracle
- expdp不導資料而匯出統計資訊導致統計資訊鎖定(ORA-20005)
- Oracle資料遷移後由列的直方圖統計資訊引起的執行計劃異常Oracle直方圖
- ORACLE表統計資訊與列統計資訊Oracle
- ORACLE表統計資訊與列統計資訊、索引統計資訊Oracle索引
- 檢視oracle被鎖的表是誰鎖的Oracle
- MySQL 由於MDL讀鎖select被阻塞MySql
- 深入分割槽表的增量統計資訊收集技術(incremetal statistics collection)REM
- ORACLE 鎖表的解決方法及查詢引起鎖表SQL語句[轉]OracleSQL
- ORACLE 鎖表的解決方法及查詢引起鎖表SQL語句方法OracleSQL
- 物件統計資訊鎖定的解決辦法(ORA-20005/ORA-38029)物件
- Fixed Objects Statistics統計資訊收集 - 2Object
- Oracle 11g新特性:多列統計資訊(MultiColumn Statistics)Oracle
- 由於內部連線引起的Oracle RAC效能問題Oracle
- 刪除oracle表被鎖住Oracle
- (轉)學習Oracle動態效能表-(3)V$LOCK,V$LOCKED_OBJECTOracleObject
- 重新收集oracle表的統計資訊Oracle
- 一個由於侵入框架引起的故障框架
- 監視stale statistics(失真的統計資訊)的物件!物件
- 轉:Oracle 解鎖Record is locked by another useOracle
- EMD_MAINTENANCE 引起統計資訊收集AINaN
- 【STATS】Oracle遷移表統計資訊Oracle
- oracle檢視和更新統計表的資訊Oracle
- oracle自治事務引起的死鎖Oracle
- 由Oracle Bug引起的AWR Snapshot收集故障Oracle
- Oracle 11g 密碼過期被鎖報 ORA-28000 the account is lockedOracle密碼
- 關於ORACLE自動統計CBO統計資訊Oracle
- 使用者被鎖-中介軟體配置引起的