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博客

相关推荐
XXYBMOOO28 分钟前
基于 Qt 的 BMP 图像数据存取至 SQLite 数据库的实现
数据库·c++·qt
Sunlight_7771 小时前
第五章 SQLite数据库:1、SQLite 基础语法及使用案例
java·linux·服务器·jvm·数据库·tcp/ip·sqlite
嘉嘉king1 小时前
Mysql联表查询
数据库
镜舟科技2 小时前
NoSQL 与 NewSQL 全面对比:如何选择适合你的数据库方案?
数据库·starrocks·nosql·newsql·技术架构·实时数据分析
TDengine (老段)2 小时前
TDengine 语言连接器(Node.js)
大数据·c语言·数据库·物联网·node.js·时序数据库·tdengine
Sunlight_7772 小时前
第五章 SQLite数据库:3、SQLite 常用语法及使用案例
jvm·数据库·sqlite
数据库砖家3 小时前
YashanDB|虚拟内存高出实际内存十几G?原因不只是“占用大”这么简单
数据库
郭源潮13 小时前
《MySQL:MySQL表结构的基本操作》
数据库·mysql
火龙谷4 小时前
【hive】Hive对数据库,对表的操作(一)
数据库·hive·hadoop