日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

索引unusable|disable|enable

發(fā)布時間:2024/8/26 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 索引unusable|disable|enable 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

ORACLE使索引變成不可用的狀態(tài):
alter index index_name unusable;
執(zhí)行成功后,如果后續(xù)需要再用到該索引的話,就必須重建。重建后會自動變成usable。
根據(jù)ORACLE官方文檔的說法(An unusable index must be rebulit , or dropped and re-created , before it can be used.)
重建有兩種方式
1. rebuild
?? alter index index_name rebuild;
2. drop掉該索引,然后再重建。
?? drop index index_name;
?? create index index_name on xxxxx;
實(shí)際上這兩種操作的結(jié)果是一樣的,都是刪除再重新啟用,不過rebulid方式更為快捷和簡單。

另外,數(shù)據(jù)庫還有兩種修改INDEX狀態(tài)的語句,叫disable和enable;

1. enable index
?? alter index index_name enable;
2. disable index
?? alter index index_name disable;


兩者的區(qū)別是:enable和disable僅僅只針對函數(shù)索引。
ORACLE官方文檔提供的說法是:

ENABLE Clause

Enable applies only to a function-based index that has been disabled because a user-defined function used by the index was dropped or replaced. This clause enables such an index if these conditions are true:

The function is currently valid

The signature of the current function matches the signature of the function when the index was created

The function is currently marked asDETERMINISTIC

Restriction on Enabling Function-based Indexes You cannot specify any other clauses of ALTER INDEX in the same statement with ENABLE.

DISABLE Clause

DISABLE applies only to a function-based index. This clause lets you disable the use of a function-based index. You might want to do so, for example, while working on the body of the function. Afterward you can either rebuild the index or specify another ALTER INDEX statement with the ENABLE keyword.

UNUSABLE Clause

Specify UNUSABLE to mark the index or index partition(s) or index subpartition(s) UNUSABLE. An unusable index must be rebuilt, or dropped and re-created, before it can be used. While one partition is marked UNUSABLE, the other partitions of the index are still valid. You can execute statements that require the index if the statements do not access the unusable partition. You can also split or rename the unusable partition before rebuilding it.

Restriction on Marking Indexes Unusable You cannot specify this clause for an index on a temporary table.

如果發(fā)現(xiàn)一個索引失效以后,對其使用enable命令,可能會引發(fā)ORA-02243的錯誤,這是由于ENABLE只針對函數(shù)索引有效,可以試試rebuild,如果對一個索引執(zhí)行失效命令,也可能會遇到這個錯誤,原因是一樣的。
因此,修改你的命令就可以啦~~

總結(jié)

以上是生活随笔為你收集整理的索引unusable|disable|enable的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

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