使用authid current_user语句可以动态授权;可以指定索引表空间;
CREATE OR REPLACE PROCEDURE rebuildindx
authid current_user
IS
/******************************************************************************
NAME: add_column
PURPOSE:
REVISIONS:
Ver Date Author Description
--------- ---------- --------------- ------------------------------------
1.0 2009/4/28 1. Created this procedure.
NOTES:
Automatically available Auto Replace Keywords:
Object Name: add_column
Sysdate: 2009/4/28
Date and Time: 2009/4/28, 14:06:28, and 2009/4/28 14:06:28
Username: (set in TOAD Options, Procedure Editor)
Table Name: (set in the "New PL/SQL Object" dialog)
******************************************************************************/
v_statement VARCHAR2 (2000);
BEGIN
FOR objectname IN
(SELECT 'alter index '
|| index_name
|| ' rebuild online nologging tablespace 索引表空间名 AS sql1
--修改tablespace name
FROM user_indexes
WHERE index_type = 'NORMAL'
AND table_name NOT IN
('xxx', 'xxxx'))
LOOP
BEGIN
v_statement := objectname.sql1;
--dbms_output.put_line (v_statement);
EXECUTE IMMEDIATE v_statement;
EXCEPTION
WHEN OTHERS
THEN
RAISE;
END;
END LOOP;
END rebuildindx;
/