进行在线创建索引操作时会话中断,索引处于中间状态。这时尝试删除、重建或rename该索引时,出现如下报错:
ora-08104:该索引对象216832正在被连接建立或重建
一般可以等SMON后台进程进行自动清理。也可以使用DBMS_REPAIR.ONLINE_INDEX_CLEAN进行手工清理。
语法:
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;
如果清理成功,返回TRUE;如果存在未清理成功的对象,则返回FALSE
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.
简单调用:
SQL> conn / as sysdba
SQL> DECLARE
isClean BOOLEAN;
BEGIN
isClean := DBMS_REPAIR.ONLINE_INDEX_CLEAN();
END;
/
实际遇到的问题等了四十多分钟后自动清理的。查了一下SMON进程的trace文件,没有记录相关信息。
参考:
How to Cleanup and Rebuild an Interrupted Online Index Rebuild - ORA-8104 , ORA-8106 (Doc ID 272735.1)