10g中DBA_TAB_STATISTICS的STATTYPE_LOCKED列對分割槽鎖定顯示為空

yangtingkun發表於2012-07-18

Oracle10gDBA_TAB_STATISTICS檢視的STATTYPE_LOCKED列沒有正確的顯示結果。

 

 

看一個簡單的例子:

SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
PL/SQL Release 10.2.0.5.0 - Production
CORE 10.2.0.5.0 Production
TNS for Linux: Version 10.2.0.5.0 - Production
NLSRTL Version 10.2.0.5.0 - Production

SQL> create table t_part (id number, name varchar2(30))
  2  partition by range (id)
  3  (partition p1 values less than (10),
  4  partition p2 values less than (20),
  5  partition pmax values less than (maxvalue));

Table created.

SQL> select table_name, partition_name, stattype_locked from all_tab_statistics where wner = user and table_name = 'T_PART';

TABLE_NAME                     PARTITION_NAME                 STATT
------------------------------ ------------------------------ -----
T_PART
T_PART                         P1
T_PART                         P2
T_PART                         PMAX

SQL> exec dbms_stats.lock_partition_stats(user, 'T_PART', 'P1')

PL/SQL procedure successfully completed.

SQL> select table_name, partition_name, stattype_locked from all_tab_statistics where wner = user and table_name = 'T_PART';

TABLE_NAME                     PARTITION_NAME                 STATT
------------------------------ ------------------------------ -----
T_PART
T_PART                         P1
T_PART                         P2
T_PART                         PMAX

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

PL/SQL procedure successfully completed.

SQL> select table_name, partition_name, last_analyzed, stattype_locked from all_tab_statistics where wner = user and table_name = 'T_PART';

TABLE_NAME                     PARTITION_NAME                 LAST_ANAL STATT
------------------------------ ------------------------------ --------- -----
T_PART                                                        16-JUL-12
T_PART                         P1
T_PART                         P2                             16-JUL-12
T_PART                         PMAX                           16-JUL-12

可以看到在10.2環境中,LOCK_PARTITION_STATS過程是正常工作的,但是DBA_TAB_STATISTICS檢視的STATTYPE_LOCKED列並沒有正確的顯示分割槽被鎖定的結果。

而對於表來說,LOCK_TABLE_STATS過程執行後,STATTYPE_LOCKED的結果顯示是正常的:

SQL> exec dbms_stats.lock_table_stats(user, 'T_PART')

PL/SQL procedure successfully completed.

SQL> select table_name, partition_name, last_analyzed, stattype_locked from all_tab_statistics where wner = user and table_name = 'T_PART';

TABLE_NAME                     PARTITION_NAME                 LAST_ANAL STATT
------------------------------ ------------------------------ --------- -----
T_PART                                                        16-JUL-12 ALL
T_PART                         P1                                       ALL
T_PART                         P2                             16-JUL-12 ALL
T_PART                         PMAX                           16-JUL-12 ALL

這說明在10.2中,Oracle對於分割槽列的鎖定的支援是存在問題的。查詢了一下MOSOracle將這個問題確認為內部BUG7240460,這個問題在11.1.0.7中被FIXED

而在11.2中,這個問題以及不存在了:

SQL> select * from v$version;

BANNER
----------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE    11.2.0.3.0      Production
TNS for Solaris: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production

SQL> select owner, table_name, partition_name, stattype_locked
  2  from dba_tab_statistics
  3  where wner = 'TEST'
  4  and table_name = 'T_PART';

OWNER      TABLE_NAME   PARTITION_NAME  STATT
---------- ------------ --------------- -----
TEST       T_PART
TEST       T_PART       P2
TEST       T_PART       P3
TEST       T_PART       P4
TEST       T_PART       P5
TEST       T_PART       PMAX

6 rows selected.

SQL> exec dbms_stats.lock_partition_stats('TEST', 'T_PART', 'P2')

PL/SQL procedure successfully completed.

SQL> select owner, table_name, partition_name, stattype_locked
  2  from dba_tab_statistics
  3  where wner = 'TEST'
  4  and table_name = 'T_PART';

OWNER      TABLE_NAME   PARTITION_NAME  STATT
---------- ------------ --------------- -----
TEST       T_PART
TEST       T_PART       P2              ALL
TEST       T_PART       P3
TEST       T_PART       P4
TEST       T_PART       P5
TEST       T_PART       PMAX

6 rows selected.

 

 

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

相關文章