How do you set Incemental to true for multiple tables with the same owner using DBMS_STATS.set_table_prefs?

后端 未结 1 1900
攒了一身酷
攒了一身酷 2021-01-14 19:27

I have around 40-50 tables in my oracle database that are partitioned. Using DBMS_STATS.set_table_prefs, I want to set \"Incremental\" to true for all of my partitioned tab

相关标签:
1条回答
  • 2021-01-14 19:57

    This PL/SQL block (which is based on your comment in another question) loops through partitioned tables for a user and sets their incremental preference to 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;
    /
    
    0 讨论(0)
提交回复
热议问题