请问这个oracle删除用户全部的表的语句怎么做成bat执行文件啊

declare
cursor c1 is select table_name from dba_tables where owner='REPORT';
begin
for c2 in c1 loop
execute immediate 'drop table REPORT.'||c2.table_name;
end loop;
end;
这个语句是oracle中删除report用户全部表的sql程序
我在pl developer中可以执行,但把这个做成sql文件后用bat命令执行就执行不了(程序不动)
请问怎么办啊?

把删除全部表的程序写到一个XXX.sql的文件中,把这个文件放在D盘下
declare
cursor c1 is select table_name from dba_tables where owner='REPORT';
begin
for c2 in c1 loop
execute immediate 'drop table REPORT.'||c2.table_name;
end loop;
end;
exit;
注意事项:末尾加上exit;

然后在做一个bat文件。例如XXX.bat,把这个文件也放在D盘下(只要保证.sql和bat在同一目录下就行了)
bat里面的内容:
cmd /c sqlplus 用户名/密码@SID @D:\XXX.sql
pause

双击bat就OK了
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-08-03
.bat的内容如下:
sqlplus 用户名/密码@SID
declare
cursor c1 is select table_name from dba_tables where owner='REPORT';
begin
for c2 in c1 loop
execute immediate 'drop table REPORT.'||c2.table_name;
end loop;
end;
exit;

最快的方式实际上还是:
drop user username cascade;
create user username identified by passwd default tablespace tablespace_name;
grant connect,resource to username;
第2个回答  2010-07-31
drop user rose cascade,这用就删掉了和这个用户相关的所有表和资源了。
相似回答