更新指定用户索引的统计信息:
CREATE OR REPLACE PROCEDURE GATHER_INDEX_STATS(V_OWNER VARCHAR(50))
AS
BEGIN
FOR REC IN(SELECT OWNER,INDEX_NAME,TABLE_NAME FROM ALL_INDEXES WHERE OWNER=V_OWNER AND INDEX_TYPE<>‘BITMAP’)
LOOP
BEGIN
CALL DBMS_STATS.GATHER_INDEX_STATS(REC.OWNER,REC.INDEX_NAME,NULL,100);
EXCEPTION WHEN OTHERS THEN
PRINT REC.TABLE_NAME||’-’||REC.INDEX_NAME;
END;
END LOOP;
END;
CALL GATHER_INDEX_STATS(‘OWER’);
更新指定用户统计信息:
CALL DBMS_STATS.GATHER_SCHEMA_STATS(‘OWNER’,100,FALSE,‘FOR ALL COLUMNS SIZE AUTO’)