Maison  >  Article  >  base de données  >  细说ORA-08104错误

细说ORA-08104错误

WBOY
WBOYoriginal
2016-06-07 17:33:231300parcourir

在线重建索引 (alter index index_name rebuild online)虽然延长了索引重建的时间,却也赋予了我们在线重建索引,提高数据可用性

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

在线重建索引的过程中,Oracle数据库会修改数据字典表,并生成中间表(IOT)来记录索引重建期间发生的dml操作。如果重建过程异常中断,smon进程会清理重建痕迹,但是如果系统非常繁忙导致smon应接不暇或者dml操作过多导致smon无法获取相关表上的锁,从而无法清理重建痕迹,当我们再次重建索引时,就会产生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错误,就要清除重建痕迹,总结方法如下:

 

 

  • ONLINE_INDEX_CLEAN Function
  •  

     

    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

    DBMS_REPAIR.ONLINE_INDEX_CLEAN ( object_id IN BINARY_INTEGER DEFAULT ALL_INDEX_ID, wait_for_lock IN BINARY_INTEGER DEFAULT LOCK_WAIT) RETURN BOOLEAN;

    Parameters

    Table 79-8 ONLINE_INDEX_CLEAN Function Parameters

    ParameterDescription

    object_id

    Object id of index to be cleaned up. The default cleans up all object ids that qualify.

    wait_for_lock

    This parameter specifies whether to try getting DML locks on underlying table [[sub]partition] object. The default retries up to an internal retry limit, after which the lock get will give up. If LOCK_NOWAIT is specified, then the lock get does not retry.

    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 过程已成功完成。

    更多详情见请继续阅读下一页的精彩内容:

    相关阅读:

    ORA-01172、ORA-01151错误处理

    ORA-00600 [2662]错误解决

    ORA-01078 和 LRM-00109 报错解决方法

    ORA-00471 处理方法笔记

    ORA-00314,redolog 损坏,或丢失处理方法

    ORA-00257 归档日志过大导致无法存储的解决办法

    linux

    Déclaration:
    Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn