How to drop all user tables?

2019-01-29 14:49发布

How can I drop all user tables in oracle?

I have problem with constraints. When I disable all it is still no possible.

8条回答
ゆ 、 Hurt°
2楼-- · 2019-01-29 15:21

The simplest way is to drop the user that owns the objects with the cascade command.

DROP USER username CASCADE
查看更多
我只想做你的唯一
3楼-- · 2019-01-29 15:24

The easiest way would be to drop the tablespace then build the tablespace back up. But I'd rather not have to do that. This is similar to Henry's except that I just do a copy/paste on the resultset in my gui.

SELECT
  'DROP'
  ,object_type
  ,object_name
  ,CASE(object_type)
     WHEN 'TABLE' THEN 'CASCADE CONSTRAINTS;'
     ELSE ';'
   END
 FROM user_objects
 WHERE
   object_type IN ('TABLE','VIEW','PACKAGE','PROCEDURE','FUNCTION','SEQUENCE')
查看更多
登录 后发表回答