Oracle SQL * PLUS-delete all objects of the current user

Source: Internet
Author: User

--. SQL script
-- The only note is that f: \ dropobj. SQL is the operated. SQL;
-- Your computer does not have a drive F. Replace it with drive D or E.
-- Used to delete all objects of the current user
-- Use for drop all objects in current user;
Set heading off;
Set feedback off;
Spool f: \ dropobj. SQL;
 
Prompt -- delete Constraints
Select 'alter table' | table_name | 'drop constraint' | constraint_name | ';'
From user_constraints where constraint_type = 'R ';
 
Prompt -- delete a tablespace
Select 'drop table' | table_name | ';' from user_tables;
 
Prompt -- delete View
Select 'drop view' | view_name | ';' from user_views;
 
Prompt -- delete a sequence of numbers
Select 'drop sequence '| sequence_name |'; 'from user_sequences;
 
Prompt -- delete a function
Select 'drop function' | object_name | ';' from user_objects
Where object_type = 'function ';

Prompt -- delete a stored procedure
Select 'drop procedure '| object_name |'; 'from user_objects
Where object_type = 'processure ';
 
Prompt -- delete a package
Prompt -- delete Package content
Select 'drop package' | object_name | ';' from user_objects
Where object_type = 'package ';

Prompt -- delete a database link
Select 'drop database link' | object_name | ';' from user_objects
Where object_type = 'database link ';
 
Spool off;
Set heading on;
Set feedback on;

@ F: \ dropobj. SQL;
Host del f: \ dropobj. SQL;
-- Done for drop objects in current user;
-- Import the entire segment in SQL * PLUS as. SQL or directly copy and paste it, and press F5 to complete the operation.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.