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

情到浓时终转凉″ 提交于 2019-12-01 08:40:54

问题


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 tables. Can anyone help me with this?

Below is the query:

SELECT DISTINCT (table_name), partitioning_type, subpartitioning_type, OWNER FROM all_part_tables WHERE OWNER = 'user' ORDER BY table_name ASC ;


回答1:


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;
/


来源:https://stackoverflow.com/questions/50258372/how-do-you-set-incemental-to-true-for-multiple-tables-with-the-same-owner-using

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!