在INDEX 處於UNABLE 狀態下插入資料
在環境上把一個INDEX 處於unusable狀態:
這是一個9IR2的環境
SQL> create table test as select * from dba_objects;
Table created.
SQL> insert into test select * from dba_objects;
34084 rows created.
SQL> create index i_test_1 on test(object_id);
Index created.
SQL> alter index i_test_1 unusable;
Index altered.
這時對TABLE 進行 dml操作時,如果dml語句沒有對test.object_id 自動進行操作時,語句可以正常操作。
但如果包括了test.object_id 欄位,sql會報錯:
SQL> update test set OBJECT_ID = 2000;
update test set OBJECT_ID = 2000
*
ERROR at line 1:
ORA-01502: index 'SYS.I_TEST_1' or partition of such index is in unusable state
SQL> insert into test select * from dba_objects;
insert into test select * from dba_objects
*
ERROR at line 1:
ORA-01502: index 'SYS.I_TEST_1' or partition of such index is in unusable state
SQL> insert /*+ append */ into test select * from dba_objects;
2
SQL> insert /*+ append */ into test select * from dba_objects;
insert /*+ append */ into test select * from dba_objects
*
ERROR at line 1:
ORA-26028: index SYS.I_TEST_1 initially in unusable state
可以看到在9I下,如果對含有UNUSABLES INDEX 欄位的table進行dml操作,ORACLE是不允許的。
要解決這個問題,那需要在當前session中更改SKIP_UNUSABLE_INDEXES 為true。
執行的指令碼:
SQL> alter session set SKIP_UNUSABLE_INDEXES =true;
Session altered.
SQL> insert /*+ append */ into test select * from dba_objects;
34085 rows created.
SQL> select status from user_indexes where index_name='I_TEST_1';
STATUS
------------------------
UNUSABLE
SQL> alter index I_TEST_1 rebuild;
Index altered.
SQL> select status from user_indexes where index_name='I_TEST_1';
STATUS
------------------------
VALID
在10g下, oracle可以忽略DML 語句中含有unusable index的欄位。原因是skip_unusable_indexes 引數從9I的會話級別的
上升到INSTANCE級別的。
而且預設值為TRUE.
SQL> select * from v$version where rownum < 2;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
SQL> show parameter skip
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
skip_unusable_indexes boolean TRUE
SQL> create table test as select * from dba_objects;
Table created.
SQL> insert into test select * from dba_objects;
50008 rows created.
SQL> create index i_test_1 on test(object_id);
Index created.
SQL> alter index i_test_1 unusable;
Index altered.
SQL> insert /*+ append */ into test select * from dba_objects;
50009 rows created.
SQL> select status from user_indexes where index_name='I_TEST_1';
STATUS
--------
UNUSABLE
SQL> alter index I_TEST_1 rebuild;
Index altered.
SQL> select status from user_indexes where index_name='I_TEST_1';
STATUS
--------
VALID
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/40239/viewspace-573313/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- shutdown資料庫後提示資料庫處於running狀態資料庫
- Oracle 在mount狀態下重新命名資料檔案Oracle
- 在open狀態下恢復丟失的資料檔案
- picc某rac資料庫無法連線,資料庫處於開啟狀態。資料庫
- SESSION處於KILLED狀態下如何找出對應的程式Session
- 在open狀態下恢復未備份的資料檔案
- 3.4.2 將資料庫置於 Quiesced 狀態資料庫UI
- 案例:在open狀態下恢復未備份的資料檔案
- SQLServer資料庫處於恢復掛起狀態的解決辦法SQLServer資料庫
- 在RFT中如何等待瀏覽器處於Ready狀態?瀏覽器
- CRM下載物件一直處於Wait狀態的原因物件AI
- 海量資料處理_批量插入
- Unable to create git index lockGitIndex
- 如果INDEX表空間滿了,資料是否可以插入Index
- 在 Laravel 的資料庫模型中使用狀態模式Laravel資料庫模型模式
- Jtti:SQLServer資料庫處於恢復掛起狀態的解決辦法JttiSQLServer資料庫
- 測試恢復3==當資料庫處於開啟狀態時的恢復資料庫
- 理解資料狀態管理
- oracle資料庫狀態Oracle資料庫
- 【DUAL】資料庫nomount狀態下DUAL的內容資料庫
- GetStartupInfo檢測程式處於被除錯狀態除錯
- 資料庫啟動在mount狀態,無任何報錯資料庫
- hive 動態分割槽插入資料表Hive
- 由於管理員的策略 ,該磁碟處於離線狀態
- mybatis插入資料、批量插入資料MyBatis
- 資料庫訂單狀態資料庫
- 計算資料庫有多少工作是在最優狀態下進行的語句資料庫
- Hbase 之 某Region長期處於 RIT 狀態 ( 空洞 )
- MogDB備機處於standby need-repair(WAL)狀態AI
- Oracle資料庫的靜默狀態和掛起狀態Oracle資料庫
- 在狀態列中插入類似進度條的可視控制元件控制元件
- openguass 資料庫狀態查詢資料庫
- oracle資料庫例項狀態Oracle資料庫
- 初始化遊戲狀態資料遊戲
- 儲存NETAPP處於takeover狀態解決方法。APP
- 網路問題或客戶端異常可能導致資料庫會話處於僵死狀態客戶端資料庫會話
- 關於tablespace在read only狀態下的DML ,DDL操作--Read-Only Tablespaces
- Elasticsearch叢集狀態健康值處於red狀態問題分析與解決(圖文詳解)Elasticsearch