细说ORA-08104错误

2014-11-24 17:40:50 · 作者: · 浏览: 0

在线重建索引 (alter index index_name rebuild online)虽然延长了索引重建的时间,却也赋予了我们在线重建索引,提高数据可用性的能力。如果在联机重建索引的过程中出现错误,如用户终止,网络中断等,那么当我们再次重建索引时,有可能会产生ORA-08104错误。这是由于先前的操作痕迹没有清除而造成的。


下面我们构造一个ora-08104错误


--session 1
SQL> alter index ind1 rebuild online;
--session 2
SQL> update tab1 set rn = rn+1;
--session 1 网络故障,断线
--session 2
SQL> update tab1 set rn = rn+1;


已更新499999行。


SQL> COMMIT;
--session 3
SQL> alter index ind1 rebuild online;
alter index ind1 rebuild online
*
第 1 行出现错误:
ORA-08104: 该索引对象 87859 正在被联机建立或重建


要解决ora-08104错误,就要清除重建痕迹,总结方法如下:






This function performs a manual cleanup of failed or interrupted online index builds or rebuilds. This action is also performed periodically by SMON, regardless of user-initiated cleanup.


This function returns TRUE if all indexes specified were cleaned up and FALSE if one or more indexes could not be cleaned up.


Syntax


Parameters


declare
isclean boolean;
begin
isclean :=false;
while isclean=false
loop
isclean := DBMS_REPAIR.ONLINE_INDEX_CLEAN(dbms_repair.all_index_id,dbms_repair.lock_wait);
dbms_lock.sleep(10);
end loop;
10 end;
11 /


PL/SQL 过程已成功完成。


相关阅读