日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

oracle分区大批量update,Oracle 对分区作调整记得加update global indexes

發(fā)布時間:2024/9/30 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 oracle分区大批量update,Oracle 对分区作调整记得加update global indexes 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

Oracle 對分區(qū)做調整記得加update global indexes

在對分區(qū)做ddl操作時,會使分區(qū)全局索引失效,需要加上關鍵字update global indexes。

SQL> select * from v$version;

BANNER

--------------------------------------------------------------------------------

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

PL/SQL Release 11.2.0.1.0 - Production

CORE ? ?11.2.0.1.0 ? ? ?Production

TNS for 32-bit Windows: Version 11.2.0.1.0 - Production

NLSRTL Version 11.2.0.1.0 - Production

drop table t_range purge;

create table t_range (id number not null PRIMARY KEY, test_date date)

partition by range (test_date)

(

partition p_2014_11 values less than (to_date('2014-11-01', 'yyyy-mm-dd')),

partition p_2014_12 values less than (to_date('2014-12-01', 'yyyy-mm-dd')),

partition p_2015_01 values less than (to_date('2015-01-01', 'yyyy-mm-dd')),

partition p_2015_02 values less than (to_date('2015-02-01', 'yyyy-mm-dd')),

partition p_2015_03 values less than (to_date('2015-03-01', 'yyyy-mm-dd'))

);

insert /*+append */ into t_range ?select rownum,

to_date(to_char(sysdate - 140, 'J') +

trunc(dbms_random.value(0, 80)),

'J')

from dual

connect by rownum <= 100000;

create index ind_t_range_date on t_range(test_date) nologging;

select * from t_range;

exec dbms_stats.gather_table_stats(user,'t_range',cascade => true);

set autotrace traceonly

select /*+index(t_range ind_t_range_date)*/count(1) from t_range where

test_date = TO_DATE('2015-01-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss');

執(zhí)行計劃

----------------------------------------------------------

Plan hash value: 2542800765

--------------------------------------------------------------------------------------

| Id ?| Operation ? ? ? ? | Name ? ? ? ? ? ? | Rows ?| Bytes | Cost (%CPU)| Time ? ? |

--------------------------------------------------------------------------------------

| ? 0 | SELECT STATEMENT ?| ? ? ? ? ? ? ? ? ?| ? ? 1 | ? ? 8 | ? ?23 ? (0)| 00:00:01 |

| ? 1 | ?SORT AGGREGATE ? | ? ? ? ? ? ? ? ? ?| ? ? 1 | ? ? 8 | ? ? ? ? ? ?| ? ? ? ? ?|

|* ?2 | ? INDEX RANGE SCAN| IND_T_RANGE_DATE | ?1243 | ?9944 | ? ?23 ? (0)| 00:00:01 |

--------------------------------------------------------------------------------------

Predicate Information (identified by operation id):

---------------------------------------------------

2 - access("TEST_DATE"=TO_DATE(' 2015-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))

統(tǒng)計信息

----------------------------------------------------------

1 ?recursive calls

0 ?db block gets

6 ?consistent gets

0 ?physical reads

0 ?redo size

424 ?bytes sent via SQL*Net to client

415 ?bytes received via SQL*Net from client

2 ?SQL*Net roundtrips to/from client

0 ?sorts (memory)

0 ?sorts (disk)

1 ?rows processed

set autotrace off

alter table t_range drop partition p_2014_11;

set autotrace traceonly

select /*+index(t_range ind_t_range_date)*/count(1) from t_range where

test_date = TO_DATE('2015-01-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss');

select /*+index(t_range ind_t_range_date)*/count(1) from t_range where

*

第 1 行出現(xiàn)錯誤:

ORA-01502: 索引 'TEST.IND_T_RANGE_DATE' 或這類索引的分區(qū)處于不可用狀態(tài)

set autotrace off;

alter index ind_t_range_date rebuild nologging;

alter table t_range drop partition p_2014_12 update global indexes;

set autotrace traceonly

select /*+index(t_range ind_t_range_date)*/count(1) from t_range where

test_date = TO_DATE('2015-01-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss');

執(zhí)行計劃

----------------------------------------------------------

Plan hash value: 2542800765

--------------------------------------------------------------------------------------

| Id ?| Operation ? ? ? ? | Name ? ? ? ? ? ? | Rows ?| Bytes | Cost (%CPU)| Time ? ? |

--------------------------------------------------------------------------------------

| ? 0 | SELECT STATEMENT ?| ? ? ? ? ? ? ? ? ?| ? ? 1 | ? ? 8 | ? ?13 ? (0)| 00:00:01 |

| ? 1 | ?SORT AGGREGATE ? | ? ? ? ? ? ? ? ? ?| ? ? 1 | ? ? 8 | ? ? ? ? ? ?| ? ? ? ? ?|

|* ?2 | ? INDEX RANGE SCAN| IND_T_RANGE_DATE | ?1243 | ?9944 | ? ?13 ? (0)| 00:00:01 |

--------------------------------------------------------------------------------------

Predicate Information (identified by operation id):

---------------------------------------------------

2 - access("TEST_DATE"=TO_DATE(' 2015-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))

統(tǒng)計信息

----------------------------------------------------------

1 ?recursive calls

0 ?db block gets

6 ?consistent gets

0 ?physical reads

0 ?redo size

424 ?bytes sent via SQL*Net to client

415 ?bytes received via SQL*Net from client

2 ?SQL*Net roundtrips to/from client

0 ?sorts (memory)

0 ?sorts (disk)

1 ?rows processed

set autotrace off;

總結

以上是生活随笔為你收集整理的oracle分区大批量update,Oracle 对分区作调整记得加update global indexes的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。