我的oracle数据库中有大约40-50个表被分区。使用DBMS_STATS.set_table_prefs,我想为所有分区表将“Incremental”设置为true。任何人都可以帮我这个吗?
以下是查询:
SELECT DISTINCT(table_name),partitioning_type,subpartitioning_type,OWNER 来自all_part_tables 在哪里OWNER ='用户' ORDER BY table_name ASC;
答案 0 :(得分:2)
此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;
/