- I have a Oracle database backup file (.dmp) that was created with expdp.
- The .dmp file was an export of an entire database.
- I need to restore 1 of the schemas from within this dump file.
- I dont know the names of the schemas inside this dump file.
- To use impdp to import the data i need the name of the schema to load.
So, I need to inspect the .dmp file and list all of the schemas in it, how do i do that?
Update (2008-09-18 13:02) - More detailed information:
The impdp command i'm current using is:
impdp user/password@database directory=DPUMP_DIR
dumpfile=EXPORT.DMP logfile=IMPORT.LOG
And the DPUMP_DIR is correctly configured.
SQL> SELECT directory_path
2 FROM dba_directories
3 WHERE directory_name = 'DPUMP_DIR';
DIRECTORY_PATH
-------------------------
D:\directory_path\dpump_dir\
And yes, the EXPORT.DMP file is infact in that folder.
The error message I get when I run the impdp command is:
Connected to: Oracle Database 10g Enterprise Edition ...
ORA-31655: no data or metadata objects selected for job
ORA-39154: Objects from foreign schemas have been removed from import
This error message is mostly expected. I need the impdp command be:
impdp user/password@database directory=DPUMP_DIR dumpfile=EXPORT.DMP
SCHEMAS=SOURCE_SCHEMA REMAP_SCHEMA=SOURCE_SCHEMA:MY_SCHEMA
But to do that, I need the source schema.
impdp
exports the DDL of admp
backup to a file if you use theSQLFILE
parameter. For example, put this into a text fileThen check
ddl_dump.txt
for the tablespaces, users, and schemas in the backup.According to the documentation, this does not actually modify the database:
If you open the DMP file with an editor that can handle big files, you might be able to locate the areas where the schema names are mentioned. Just be sure not to change anything. It would be better if you opened a copy of the original dump.
My solution (similar to KyleLanser's answer) (on a Unix box):
Update (2008-09-19 10:05) - Solution:
My Solution: Social engineering, I dug real hard and found someone who knew the schema name.
Technical Solution: Searching the .dmp file did yield the schema name.
Once I knew the schema name, I searched the dump file and learned where to find it.
Places the Schemas name were seen, in the .dmp file:
<OWNER_NAME>SOURCE_SCHEMA</OWNER_NAME>
This was seen before each table name/definition.SCHEMA_LIST 'SOURCE_SCHEMA'
This was seen near the end of the .dmp.Interestingly enough, around the
SCHEMA_LIST 'SOURCE_SCHEMA'
section, it also had the command line used to create the dump, directories used, par files used, windows version it was run on, and export session settings (language, date formats).So, problem solved :)
The running the impdp command to produce an sqlfile, you will need to run it as a user which has the DATAPUMP_IMP_FULL_DATABASE role.
Or... run it as a low privileged user and use the MASTER_ONLY=YES option, then inspect the master table. e.g.
http://download.oracle.com/otndocs/products/database/enterprise_edition/utilities/pdf/oow2011_dp_mastering.pdf
Step 1: Here is one simple example. You have to create a SQL file from the dump file using
SQLFILE
option.Step 2: Grep for
CREATE USER
in the generated SQL file (here tables.sql)Example here:
Lot of datapump options explained here http://www.acehints.com/p/site-map.html