When I used imp to import a database backup in dmp format today, I found that an import error occurred and reminded that the object already exists so that I can only remember to delete all tables before importing, if the database has dozens of hundreds of tables, it would be a waste of time to delete them one by one. For convenience, I wrote a statement to query all tables and generate batch Delete statements:
Select 'drop table' | table_name | ';' as sqlscript from user_tables;
SQLSCRIPT
--------------------------------------------
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:
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.