对一张5000多万的表以online的方式建索引(online的方式为的是尽量少的影响用户使用),不止什么原因导致失败online挂起,收集表的统计信息或者删除这个索引时报ORA-08104: this index object 索引# is being online built or rebuilt。补充数据库为oracle 11g。
需要在sys的账号下执行:
DECLAREisclean BOOLEAN;
BEGIN
isclean := FALSE;
WHILE isclean = FALSE LOOP
isclean := dbms_repair.online_index_clean(object_id => dbms_repair.all_index_id,
wait_for_lock => dbms_repair.lock_wait);
dbms_lock.sleep(5);
END LOOP;
END;
select dbms_repair.online_index_clean(46) from dual;--46为索引的object_id
如果在普通用户上执行需要授权
在sys上 grant execute on dbms_repair to test; grant execute on dbms_lock to test; 普通用户上 create public synonym dbms_repair for sys.dbms_repair;