oracle删除所有表和序列,sql – 删除Oracle中的所有用户表/序列

作为我们构建过程和不断发展的数据库的一部分,我试图创建一个脚本,将删除用户的所有表和序列。我不想重新创建用户,因为这将需要更多的权限,而不是允许。

我的脚本创建一个过程来删除表/序列,执行过程,然后删除过程。我正在执行的文件从sqlplus:

drop.sql:

create or replace procedure drop_all_cdi_tables

is

cur integer;

begin

cur:= dbms_sql.OPEN_CURSOR();

for t in (select table_name from user_tables) loop

execute immediate 'drop table ' ||t.table_name|| ' cascade constraints';

end loop;

dbms_sql.close_cursor(cur);

cur:= dbms_sql.OPEN_CURSOR();

for t in (select sequence_name from user_sequences) loop

execute immediate 'drop sequence ' ||t.sequence_name;

end loop;

dbms_sql.close_cursor(cur);

end;

/

execute drop_all_cdi_tables;

/

drop procedure drop_all_cdi_tables;

/

不幸的是,删除过程会导致问题。似乎引起竞争条件,并且在执行之前该过程被丢弃。

例如。:

SQL*Plus: Release 11.1.0.7.0 - Production on Tue Mar 30 18:45:42 2010

Copyright (c) 1982, 2008, Oracle. All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Procedure created.

PL/SQL procedure successfully completed.

Procedure created.

Procedure dropped.

drop procedure drop_all_user_tables

*

ERROR at line 1:

ORA-04043: object DROP_ALL_USER_TABLES does not exist

SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64

With the Partitioning, OLAP, Data Mining and Real Application Testing options

任何想法如何得到这个工作?

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值