以前寫的的!!當然還有其他的語法可以執行analyz table
CREATE OR REPLACE PROCEDURE DB_RPT_ANALYZ_TABLE
AS
V_TABLE_NAME VARCHAR2(100);
SQL_STR VARCHAR2(500);
CURSOR USER_TABLE1 IS
SELECT TABLE_NAME FROM USER_TABLES;
BEGIN
OPEN USER_TABLE1;
LOOP
FETCH USER_TABLE1 INTO V_TABLE_NAME;
EXIT WHEN USER_TABLE1%NOTFOUND;
SQL_STR:= 'ANALYZE TABLE '''''V_TABLE_NAME''''' compute statistics';
EXECUTE IMMEDIATE SQL_STR;
END LOOP;
CLOSE USER_TABLE1;
END;
張貼留言