Oracle数组循环表存在则删除

declare

type v_arr is table of varchar2(40) index by binary_integer;

list v_arr;

existing_table number;

v_sql varchar2(200);

begin

existing_table := 0;

list(1) := 'table1';

list(2) := 'table2';

for i in 1..list.count loop

select count(*) into existing_table from all_tables where table_name=list(i) and owner='root';

if existing_table = 1 then

v_sql := 'drop table '||list(i);

execute immediate v_sql;

end if;

end loop;

commit;

end;

参考了:oracle使用数组变量,[转]Oracle数组的使用-CSDN博客

相关推荐
Rverdoser23 分钟前
【SQL】多表查询案例
数据库·sql
Galeoto25 分钟前
how to export a table in sqlite, and import into another
数据库·sqlite
人间打气筒(Ada)1 小时前
MySQL主从架构
服务器·数据库·mysql
leegong231111 小时前
学习PostgreSQL专家认证
数据库·学习·postgresql
喝醉酒的小白1 小时前
PostgreSQL:更新字段慢
数据库·postgresql
敲敲敲-敲代码1 小时前
【SQL实验】触发器
数据库·笔记·sql
和道一文字yyds1 小时前
MySQL 中的索引数量是否越多越好?为什么?如何使用 MySQL 的 EXPLAIN 语句进行查询分析?MySQL 中如何进行 SQL 调优?
数据库·sql·mysql
落笔画忧愁e2 小时前
FastGPT快速将消息发送至飞书
服务器·数据库·飞书
Σίσυφος19002 小时前
halcon 条形码、二维码识别、opencv识别
前端·数据库
小刘|3 小时前
深入理解 SQL 注入漏洞及解决方案
数据库·sql