日期:2014-05-17 浏览次数:20868 次
declare cursor tab_cur is select 'drop table '||table_name||';' from user_tables; tab_row varchar2(100); begin open tab_cur; while tab_cur%found loop fetch tab_cur into tab_row; execute immediate tab_row; end loop; close tab_cur; end;
declare cursor tab_cur is select 'drop table '||table_name from user_tables WHERE table_name='XIAODEJUN'; tab_row varchar2(100); BEGIN open tab_cur; --while tab_cur%FOUND LOOP fetch tab_cur into tab_row; EXIT WHEN tab_cur%NOTFOUND; execute immediate tab_row; end loop; close tab_cur; end;
------解决方案--------------------
declare
cursor tab_cur is select table_name from user_tables WHERE table_name='XIAODEJUN';
tab_row varchar2(100);
BEGIN
open tab_cur;
--while tab_cur%FOUND
LOOP
fetch tab_cur into tab_row;
EXIT WHEN tab_cur%NOTFOUND;
execute immediate 'drop table ' || tab_row;
end loop;
close tab_cur;
end;