Deletes all tables and views in a database in Oracle.

Source: Internet
Author: User

1. Delete All database tables

Select 'drop view' | view_name | ';' | CHR (13) | CHR (10) from user_views;

--------------------------------------------
Drop table lo_caseinfo;
Drop table lo_harmonizecase;
Drop table lo_lawcheck;
Drop table lo_legislationitem;
Drop table lo_trainbatch;
Drop table oa_impress;
Drop table oa_sysgroup;

The drop statement of all tables can be copied and executed in batches at a time.

You can also use the ignore parameter when using the IMP method to ignore existing objects and avoid Manual table deletion:


2. delete other data in the same way.

Select 'drop view' | view_name | ';' | CHR (13) | CHR (10) from user_views;
Select 'drop sequence '| sequence_name |'; '| CHR (13) | CHR (10) from user_sequences;
Select 'drop function' | object_name | ';' | CHR (13) | CHR (10) from user_objects where object_type = 'function ';
Select 'drop procedure '| object_name |'; '| CHR (13) | CHR (10) from user_objects where object_type = 'Procedure ';
Select 'drop package' | object_name | ';' | CHR (13) | CHR (10) from user_objects where object_type = 'package ';


Parameter description:

When Oracle recovers a table during data recovery, the table already exists, and you need to determine how to operate according to the ignore parameter settings.

If ignore = Y, Oracle directly inserts data into the table without executing the create table statement. If the inserted record violates the constraints, such as the primary key constraint, the error record is not inserted, however, valid records are added to the table.

If ignore = N, Oracle does not execute the create table statement and does not insert data into the table. Instead, it ignores the error of the table and continues to restore the next table.

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.