[size=large][b]按用户批量重建索引:[/b][/size]
[size=medium][b]按用户将此用户下面非临时表上面的索引全部重建,此过程建议在SYS用户下面执行:[/b][/size]
[size=medium][b]过程在SYS用户下面创建完成后,用下面的代码调整创建好的存储过程:[/b][/size]
[color=red]摘至:http://mingyue19850801.blog.163.com/blog/static/19520820201081345043380/[/color]
[size=medium][b]按用户将此用户下面非临时表上面的索引全部重建,此过程建议在SYS用户下面执行:[/b][/size]
CREATE OR REPLACE PROCEDURE BATCH_REBUILD_INDEX(USER_NAME IN VARCHAR2) IS
S_SQL VARCHAR2(500);
ACCOUNT NUMBER := 0;
BEGIN
FOR LINE2 IN (SELECT T.OWNER, T.INDEX_NAME
FROM ALL_INDEXES T
WHERE T.OWNER = UPPER(USER_NAME)
AND T.TABLE_TYPE = 'TABLE'
AND T.TEMPORARY = 'N'
AND T.INDEX_TYPE = 'NORMAL') LOOP
S_SQL := 'alter index ' || LINE2.OWNER || '.' || LINE2.INDEX_NAME ||
' rebuild';
ACCOUNT := ACCOUNT + 1;
EXECUTE IMMEDIATE S_SQL;
END LOOP;
DBMS_OUTPUT.PUT_LINE(ACCOUNT);
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM);
END BATCH_REBUILD_INDEX;
[size=medium][b]过程在SYS用户下面创建完成后,用下面的代码调整创建好的存储过程:[/b][/size]
begin
-- Call the procedure
batch_rebuild_index(user_name => 'hs_user'); --输入用户名
end;
[color=red]摘至:http://mingyue19850801.blog.163.com/blog/static/19520820201081345043380/[/color]