1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| SET SERVEROUTPUT ON SIZE 100000
DECLARE
v_dynam varchar2(200);
cursor index_cursor is
SELECT distinct owner, index_name, table_name from all_indexes ;
cursor table_cursor is
SELECT distinct owner, table_name FROM all_tables ;
nePasTraiter varchar2(500);
BEGIN
execute immediate('ALTER SESSION SET NLS_SORT=BINARY');
nePasTraiter := 'schema.table1, schema.table2';
/***************** REBUILD *************************/
for c_row in index_cursor loop
if instr(nePasTraiter, c_row.owner || '.' || c_row.table_name) = 0 then
DBMS_OUTPUT.PUT_LINE(to_char(sysdate, 'HH24:MI:SS') || ': debut de reconstruction de ' || c_row.owner || '.' || c_row.index_name);
v_dynam := 'ALTER INDEX ' || c_row.owner || '.' || c_row.index_name || ' REBUILD COMPUTE STATISTICS';
execute immediate v_dynam;
end if;
end loop;
/***************** STATISTIQUES OBJET PAR OBJET ****/
for c_row in table_cursor loop
if instr(nePasTraiter, c_row.owner || '.' || c_row.table_name) = 0 then
DBMS_OUTPUT.PUT_LINE(to_char(sysdate, 'HH24:MI:SS') || ': debut de traitement de ' || c_row.owner || '.' || c_row.table_name);
v_dynam := 'BEGIN dbms_stats.gather_table_stats(ownname =>''' || c_row.owner || ''', tabname =>''' || c_row.table_name || ''' , estimate_percent => 20, method_opt => ''for all indexed columns size 128'', cascade => false ); END;';
execute immediate v_dynam;
end if;
end loop;
END;
/ |
Partager