ORA-02243: ALTER INDEX 或 ALTER MATERIALIZED VIEW 選項無效

來源:互聯網
上載者:User

早上論壇裡一個朋友在想使索引無效的時候遇到了如下錯誤:

ORA-02243: ALTER INDEX 或 ALTER MATERIALIZED VIEW 選項無效
他使用的語句如下:

ALTER INDEX index_name DISABLE;

 

剛看到的時候我以為是由於約束存在,所以無法DISABLE索引,因為記得以前學習主鍵的過程中有個印象,刪除唯一索引時,若存在對應的主鍵約束,則不能刪除。相關的學習貼如下

http://blog.csdn.net/wh62592855/archive/2009/10/24/4724232.aspx

 

可是後來看了其他朋友的回答,去翻了翻文檔,好像並不是由於這個原因。下面從文檔中摘錄一段內容:

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 as DETERMINISTIC

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.

可以看到,DISABLE和ENABLE只針對函數索引有效,對於其他索引不行的。你可以選擇使用UNUSABLE。

下面做點實驗來看看

SQL> create table t1(id number,name varchar2(20));</p><p>Table created.</p><p>SQL> create index idx1 on t1(id);</p><p>Index created.</p><p>SQL> create index idx2 on t1(upper(name));</p><p>Index created.</p><p>SQL> alter index idx1 disable;<br />alter index idx1 disable<br />*<br />ERROR at line 1:<br />ORA-02243: invalid ALTER INDEX or ALTER MATERIALIZED VIEW option</p><p>SQL> alter index idx2 disable;</p><p>Index altered.</p><p>SQL> alter index idx1 unusable;</p><p>Index altered.</p><p>SQL> select index_name,status,funcidx_status from user_indexes where index_name<br />in ('IDX1','IDX2');</p><p>INDEX_NAME STATUS FUNCIDX_<br />------------------------------ -------- --------<br />IDX1 UNUSABLE<br />IDX2 VALID DISABLED<br />

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.