【问题标题】:How do you set Incemental to true for multiple tables with the same owner using DBMS_STATS.set_table_prefs?如何使用 DBMS_STATS.set_table_prefs 将具有相同所有者的多个表的 Incemental 设置为 true?
【发布时间】:2018-05-09 16:46:37
【问题描述】:

我的 oracle 数据库中有大约 40-50 个分区的表。使用 DBMS_STATS.set_table_prefs,我想将所有分区表的“增量”设置为 true。谁能帮我解决这个问题?

下面是查询:

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

【问题讨论】:

    标签: oracle plsql database-partitioning


    【解决方案1】:

    此 PL/SQL 块(基于您在另一个问题中的评论)循环遍历用户的分区表并将其增量首选项设置为 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;
    /
    

    【讨论】:

    • ORA-20001:BIN$Y7E8WBOCISRGU4CK/APUPA==$0 是无效标识符 ORA-06512:在“SYS.DBMS_STATS”,第 45404 行 ORA-06512:在第 9 行
    • @user9766188 我将脚本更改为忽略回收站中的表格。
    • @user9766188 我刚刚注意到另一个问题正在走同样的路。您应该删除其中一个问题,以免我们重复工作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-26
    • 1970-01-01
    • 2013-10-16
    • 2016-10-25
    • 1970-01-01
    相关资源
    最近更新 更多