• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

细说ORA-08104错误

mysql 搞代码 4年前 (2022-01-09) 92次浏览 已收录 0个评论

在线重建索引 (alter index index_name rebuild online)虽然延长了索本文来源gaodai#ma#com搞@代~码^网+引重建的时间,却也赋予了我们在线重建索引,提高数据可用性

在线重建索引 (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_idIN 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 归档日志过大导致无法存储的解决办法


    搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
    转载请注明原文链接:细说ORA-08104错误

    喜欢 (0)
    [搞代码]
    分享 (0)
    发表我的评论
    取消评论

    表情 贴图 加粗 删除线 居中 斜体 签到

    Hi,您需要填写昵称和邮箱!

    • 昵称 (必填)
    • 邮箱 (必填)
    • 网址