Oracle
 sql >> Database >  >> RDS >> Oracle

Come si imposta Incemental su true per più tabelle con lo stesso proprietario utilizzando DBMS_STATS.set_table_prefs?

Questo blocco PL/SQL (basato sul tuo commento in un'altra domanda) scorre le tabelle partizionate per un utente e imposta la sua preferenza incrementale su true.

begin
    for a in
    (
        select distinct (table_name), owner
        from all_part_tables
        where owner = 'SOME_USER_NAME'
            --Ignore objects in the recycle bin.
            --There are other "tables" that may need to be ignored, 
            --such as external tables, storage tables, etc.
            and table_name not like 'BIN$%'
        order by table_name
    ) loop
        dbms_stats.set_table_prefs(a.owner, a.table_name, 'incremental', 'true');
    end loop;
end;
/