資料泵匯入分割槽表統計資訊報錯(六)

yangtingkun發表於2009-10-06

今天在進行資料泵匯入操作時,發現一個bug

這篇文章描述問題重現的過程。

資料泵匯入分割槽表統計資訊報錯(一):http://yangtingkun.itpub.net/post/468/456176

資料泵匯入分割槽表統計資訊報錯(二):http://yangtingkun.itpub.net/post/468/456378

資料泵匯入分割槽表統計資訊報錯(三):http://yangtingkun.itpub.net/post/468/489067

資料泵匯入分割槽表統計資訊報錯(四):http://yangtingkun.itpub.net/post/468/489253

資料泵匯入分割槽表統計資訊報錯(五):http://yangtingkun.itpub.net/post/468/489433

 

 

在前面的文章中已經找到了問題的解決方法,而且在上一篇的文章中已經推測出了導致問題的大致原因。

這裡要根據前面推測的原因嘗試重現問題,來最終確定導致檔案的原因。

10.2版本的資料庫中,模仿當時的操作,利用IMP方式匯入索引,檢查是否能夠重現這個問題。

SQL> create table t_stat (id number, name varchar2(30))
  2  partition by range (id)
  3  (partition p1 values less than (10000),
  4  partition p2 values less than (20000),
  5  partition p3 values less than (maxvalue));

Table created.

SQL> insert into t_stat
  2  select rownum, object_name
  3  from dba_objects;

70959 rows created.

SQL> commit;

Commit complete.

SQL> host
[oracle@yans1 ~]$ imp test/test file=t_stat.dmp ignore=y tables=t_stat

Import: Release 10.2.0.3.0 - Production on 星期二 9 8 15:19:10 2009

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options

Export file created by EXPORT:V10.02.01 via conventional path
import done in ZHS16GBK character set and AL16UTF16 NCHAR character set
. importing TEST's objects into TEST
. importing TEST's objects into TEST
Import terminated successfully without warnings.
[oracle@yans1 ~]$ exit
exit

SQL> select table_name, index_name
  2  from user_indexes
  3  where table_name = 'T_STAT';

TABLE_NAME                     INDEX_NAME
------------------------------ ------------------------------
T_STAT                         IND_T_STAT_ID

SQL> exec dbms_stats.gather_table_stats(user, 'T_STAT')

PL/SQL procedure successfully completed.

模仿當時的情況,建立了一個分割槽表,並利用exp的邏輯備份建立索引。透過imp匯入後發現,問題並沒有重新,下面指定rows=n的方式再次執行匯入:

SQL> drop index ind_t_stat_id;

Index dropped.

SQL> host
[oracle@yans1 ~]$ imp test/test file=t_stat.dmp ignore=y tables=t_stat rows=n

Import: Release 10.2.0.3.0 - Production on 星期二 9 8 15:20:11 2009

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options

Export file created by EXPORT:V10.02.01 via conventional path
import done in ZHS16GBK character set and AL16UTF16 NCHAR character set
. importing TEST's objects into TEST
. importing TEST's objects into TEST
Import terminated successfully without warnings.
[oracle@yans1 ~]$ exit
exit

SQL> select table_name, index_name
  2  from user_indexes
  3  where table_name = 'T_STAT';

TABLE_NAME                     INDEX_NAME
------------------------------ ------------------------------
T_STAT                         IND_T_STAT_ID

SQL> exec dbms_stats.gather_table_stats(user, 'T_STAT')
BEGIN dbms_stats.gather_table_stats(user, 'T_STAT'); END;

*
ERROR at line 1:
ORA-20005: object statistics are locked (stattype = ALL)
ORA-06512: at "SYS.DBMS_STATS", line 13182
ORA-06512: at "SYS.DBMS_STATS", line 13202
ORA-06512: at line 1

這次問題重現了,現在可以確定,問題就是由於匯入的時候指定了rows=n,而使得表的統計資訊被鎖定。

下面檢查表的分析情況:

SQL> alter session set nls_date_format = 'yyyy-mm-dd hh24:mi:ss';

Session altered.

SQL> select table_name, last_analyzed        
  2  from user_tables
  3  where table_name = 'T_STAT';

TABLE_NAME                     LAST_ANALYZED
------------------------------ -------------------
T_STAT                         2009-09-08 15:20:11

下面分析當前的SCHEMA,檢查這個物件是否會被跳過:

SQL> exec dbms_stats.gather_schema_stats(user)

PL/SQL procedure successfully completed.

SQL> select table_name, last_analyzed
  2  from user_tables
  3  where table_name like 'T_S%';

TABLE_NAME                     LAST_ANALYZED
------------------------------ -------------------
TEST                           2009-09-08 15:48:59
T_STAT                         2009-09-08 15:20:11

SQL> select sysdate from dual;

SYSDATE
-------------------
2009-09-08 15:49:37

當表T_STAT的統計資訊被鎖定,收集當前SCHEMA的統計資訊時,會跳過這個表的統計資訊,這與前面碰到的現在完全一致。

至此確定了導致問題的真正原因。

 

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

相關文章