Oracle Export Schema or User And Import

Schema or User Guide – Step-by-Step

Tutorial

In this guide, we will learn how to use expdp (Data Pump Export) and impdp (Data Pump Import) in Oracle Database to back up specific schema and restore the same schema.'

To create a backup, first we have to set up a physical backup location.

Creating a Backup location:

On Linux server:

mkdir -p /data/backup





On Oracle Database:

Command:

create a directory TEST_DIR2 as '/data/backup';












Here, TEST_DIR2 is a logical directory pointing to the physical backup location.

To verify the directory:
SELECT * FROM dba_directories WHERE directory_name = 'TEST_DIR2';









Exporting a schema using expdp:

To backup the schema U1, 

expdp schemas=U1 directory=TEST_DIR2 dumpfile=schema.dump logfile=schema.log

Note: 

Dump File (.dump): A binary file generated by expdp that contains exported schema objects, data, and metadata. It is used for backup and migration.
Log File (.log): A text file that records details of the export/import process, including progress, errors, and warnings. It helps in troubleshooting.

After running the command, you will be prompted to connect the database.

Connect using sys user and press enter when asked for a password.

Export schema U1 completes successfully.










Before importing we must drop the same schema if already exists.

Why? If the schema already exists, we cannot re-import the same schema without errors.

Note: use Cascade to drop the user/schema to drop everything.

Dropped schema









Now Import the Schema using impdb:

impdp schemas=U1 directory=TEST_DIR2 dumpfile=schema.dump logfile=schema.log

Connected using the sys user when prompted.











Imported successfully, and the schema U1 restored.

Below are tables list from the user/schema U1.













Summary of Steps

✔ Created a backup directory (/data/backup) on the Linux server.

✔ Created a logical directory (test_dir2) in the Oracle Database.

✔ Exported schema U1 using expdp.

✔ Deleted the existing schema before importing.

✔ Restored U1 using impdp and verified the objects.

Final Thoughts

By following these steps, you can successfully back up and restore schema in Oracle using Data Pump Export (expdp) and Import (impdp). This method is useful for migrating data between servers or restoring accidental deletions.

👉"Did this guide help you? Have questions? Drop a comment below, and I'll be happy to help!"

👉"Want more Oracle database tutorials? Follow this blog for the latest updates!"

More useful links:

[Oracle Export Specific Tablespace And Import Specific Table only Guide – Step-by-Step Tutorial]: (https://arbnumberone.blogspot.com/2025/03/oracle-export-specific-tablespace-and.html)

[Oracle Database Export Table & Import Table Guide – Step-by-Step Tutorial]: (https://arbnumberone.blogspot.com/2025/03/export-and-import-how-to-works-in.html)

[Oracle Export Metadata only And Import the Metadata only Guide – Step-by-Step Tutorial]: (https://arbnumberone.blogspot.com/2025/03/oracle-export-metadata-only-and-import.html)








Comments

Popular posts from this blog