2 Star 0 Fork 0

mirrors_ReneNyffenegger/fatdba-Oracle-Database-Scripts

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
partitions_drop_future.sql 1.03 KB
一键复制 编辑 原始数据 按行查看 历史
Prashant Dixit 提交于 2022-03-05 22:28 . Create partitions_drop_future.sql
SET SERVEROUTPUT ON SIZE 1000000
SET ECHO ON
DECLARE
rows_found number :=1;
v_sql_to_run varchar(4000);
cursor fd_part_cursor IS
select partition_name,table_owner,table_name
from all_tab_partitions
where table_owner in ('BOOKER') and
table_name='FULFILLMENT_DEMANDS' and
partition_name >= 'FULFILLMENT_DEMANDS_20130518' order by partition_name;
BEGIN
FOR part_rec in fd_part_cursor LOOP
rows_found:=1; -- This is not needed. I am just paranoid :)
v_sql_to_run := 'select count(*) '||
'from booker.'||part_rec.table_name||' partition ('||part_rec.partition_name||') fd ';
execute immediate v_sql_to_run into rows_found;
dbms_output.put_line('--partition = '||part_rec.table_owner||'.'||part_rec.partition_name||', rows_found = '||rows_found);
if(rows_found=0) then
dbms_output.put_line('alter table booker.'||part_rec.table_name||' drop partition '||part_rec.partition_name||' update global indexes;');
end if;
END LOOP;
END;
/
SET ECHO OFF
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_ReneNyffenegger/fatdba-Oracle-Database-Scripts.git
git@gitee.com:mirrors_ReneNyffenegger/fatdba-Oracle-Database-Scripts.git
mirrors_ReneNyffenegger
fatdba-Oracle-Database-Scripts
fatdba-Oracle-Database-Scripts
main

搜索帮助