I am currently trying to import a database using DBMS_DATAPUMP in PL/SQL using the following script.
DECLARE
h1 NUMBER;
BEGIN
h1 := DBMS_DATAPUMP.OPEN('IMPORT', 'FULL', NULL, DBMS_SCHEDULER.generate_job_name, 'LATEST');
DBMS_DATAPUMP.ADD_FILE(handle => h1, filename => 'EXAMPLE6.DMP', directory => 'DUMP');
DBMS_DATAPUMP.START_JOB(h1);
dbms_datapump.detach(h1);
END;
/
Everytime I execute this code, I get the following error message.
ERROR in line 1:
ORA-39001: invalid argument value
ORA-06512: in "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: in "SYS.DBMS_DATAPUMP", line 4929
ORA-06512: in "SYS.DBMS_DATAPUMP", line 5180
ORA-06512: in line 5
I already googled the error, but the answer mostly consisted of checking if the directory was already created and if the user had read and write access to the directory.
I also tried the impdp tool just as an experiment, to see if I could execute imports that way.
impdp pdb2 directory="DUMP" dumpfile="EXAMPLE6.DMP"
Based on the user I am executing impdp as, I get different error messages.
As a user with all privileges granted:
ORA-39001: invalid argument value
ORA-39000: bad dump file specification
ORA-39155: error expanding dump file name "C:\Users\...\EXAMPLE6.DMP"
ORA-48128: opening of a symbolic link is disallowed
As the sysdba user:
ORA-39002: invalid operation
ORA-39070: unable to open the log file
ORA-39087: directory name DUMP is invalid
As I already said, the directory does exist on my drive, I created the directory called DUMP in Oracle and granted read and write access to my user.
All help would be appreciated and I would be happy to clarify if I wrote something confusing!
Edit:
Output of select directory_name, directory_path from dba_directories;
DIRECTORY_NAME
--------------------------------------------------------------------------------
DIRECTORY_PATH
--------------------------------------------------------------------------------
DUMP
C:\Users\Nemanja\Desktop\oraclePLS
I forgot to mention, that the Oracle service has complete access to the specified Windows directory.
This is how my database was exported :
exp system/password#host owner=(ifs_owner,sis_owner,emu_owner) file=file1.dmp log=file1.log direct=Y
I am trying to import it using the following commands :
1) In Oracle Developer:
create user CLIENT_TEST identified by client_test_password;
grant connect, unlimited tablespace, resource to CLIENT_TEST;
2) Next, in command line:
imp system/sys FROMUSER=(ifs_owner,sis_owner,emu_owner) TOUSER=client_test file=e:\oradata\file1.dmp
This works up to a point, (some tables are imported, however it fails with the following mesages):
. importing IFS_OWNER's objects into CLIENT_TEST
. importing SIS_OWNER's objects into SIS_OWNER
IMP-00003: ORACLE error 1435 encountered
ORA-01435: user does not exist
. importing EMU_OWNER's objects into EMU_OWNER
IMP-00003: ORACLE error 1435 encountered
ORA-01435: user does not exist
. importing IFS_OWNER's objects into CLIENT_TEST
How can i solve the errors ?
Use parfile. I mean create a parfile for your imp command and write to line as:
fromuser=ifs_owner touser=CLIENT_TEST
fromuser=sis_owner touser=CLIENT_TEST
fromuser=emu_owner touser=CLIENT_TEST
imp system/sys parfile=parfilename file=e:\oradata\file1.dmp
You can use parfile to set oracle exp and imp parameters, all parameters like as fromuser,touser,file and ... . I mean you should write a parfile (using vi or other linux editor tools) in a directory for example /home/oracle with name par1 and put your parameters like below. for each user write a line:
fromuser=ifs_owner touser=CLIENT_TEST
fromuser=sis_owner touser=CLIENT_TEST
fromuser=emu_owner touser=CLIENT_TEST
and use of this parfile in imp command:
imp system/sys parfile=/home/oracle/par1 file=e:\oradata\file1.dmp
When restoring a table from an oracle 11g backup, including more than 2 entries in the INCLUDE command returns syntax error.
The command that works is:
impdp SVC_DEMO/********* SCHEMAS=test REMAP_SCHEMA=test:SVC_DEMO REMAP_TABLESPACE=DATA:SYSTEM DIRECTORY=dmpdir DUMPFILE=devv2db_05102016.dmp TABLE_EXISTS_ACTION=replace INCLUDE = TABLE:"IN('TBLPARTNER')" LOGFILE=impschema1.log
Starting "SVC_DEMO"."SYS_IMPORT_SCHEMA_02": SVC_DEMO/********
SCHEMAS=test REMAP_SCHEMA=test:SVC_DEMO
REMAP_TABLESPACE=DATA:SYSTEM DIRECTORY=dmpdir DUMPFILE=devv2db_05102016.dmp
LOGFILE=impschema1.log
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "SVC_DEMO"."TBLPARTNER" 21.46 KB 7 rows
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "SVC_DEMO"."SYS_IMPORT_SCHEMA_02" successfully completed at 15:01:38
But, when I add a second table in the include command:
impdp SVC_DEMO/********* SCHEMAS=test REMAP_SCHEMA=test:SVC_DEMO REMAP_TABLESPACE=DATA:SYSTEM DIRECTORY=dmpdir DUMPFILE=devv2db_05102016.dmp TABLE_EXISTS_ACTION=replace INCLUDE = TABLE:"IN('TBLPARTNER', 'TBLACCOUNT')" LOGFILE=impschema1.log
I get the following message:
impdp SVC_DEMO/****** SCHEMAS=test REMAP_SCHEMA=test:SVC_DEMO
REMAP_TABLESPACE=DATA:SYSTEM DIRECTORY=dmpdir
DUMPFILE=devv2db_05102016.dmp TABLE_EXISTS_ACTION=replace INCLUDE =
TABLE:"IN('TBLPARTNER', 'TBLACCOUNT')" LOGFILE=impschema1.log
LRM-00116: syntax error at ')' following 'TBLACCOUNT'
I have looked for bugs in impdp but can't find one.
Am I doing something wrong?
Since you are running this on command line, depending on your OS, special characters may need to be escaped. (It's also easier to use a parameter file where you wont need to escape the characters)
include=TABLE:\"IN \(\'TABLE1\', \'TABLE2\'\)\"
Using a parameter file you just place one option per line and reference it with
impdp PARFILE=name.txt
When I run this command in Oracle 12c SE2:
impdp system/Oracle_1#pdborcl directory=DATA_PUMP_DIR dumpfile=mydb.dmp nologfile=Y
I get this:
ORA-39001 : invalid argument value
ORA-39000 : bad dump file specification
ORA-39088 : directory name DATA_PUMP_DIR is invalid
We used to import this into 11g all the time.
How can I solve these errors?
From the 12c documentation:
Be aware of the following requirements when using Data Pump to move data into a CDB:
...
The default Data Pump directory object, DATA_PUMP_DIR, does not work with PDBs. You must define an explicit directory object within the PDB that you are exporting or importing.
You will need to define your own directory object in your PDB, which your user (system here) has read/write privileges against.
create directory my_data_pump_dir as 'C:\app\OracleHomeUser1\admin\orcl\dpdump';
grant read, write on directory my_data_pump_dir to system;
It can be the same operating system directory that DATA_PUMP_DIR points to, you just need a separate directory object. But I've used the path you said you'd prefer, from a comment on a previous question.
Then the import is modified to have:
... DIRECTORY=my_data_pump_dir DUMPFILE=mydb.dmp
I have an 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 don't 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 in fact 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 the 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 a dmp backup to a file if you use the SQLFILE parameter. For example, put this into a text file
impdp '/ as sysdba' dumpfile=<your .dmp file> logfile=import_log.txt sqlfile=ddl_dump.txt
Then check ddl_dump.txt for the tablespaces, users, and schemas in the backup.
According to the documentation, this does not actually modify the database:
The SQL is not actually executed, and the target system remains unchanged.
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.
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 :)
Assuming that you do not have the log file from the expdp job that generated the file in the first place, the easiest option would probably be to use the SQLFILE parameter to have impdp generate a file of DDL (based on a full import). Then you can grab the schema names from that file. Not ideal, of course, since impdp has to read the entire dump file to extract the DDL and then again to get to the schema you're interested in, and you have to do a bit of text file searching for the various CREATE USER statements, but it should be doable.
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.
select value_t
from SYS_IMPORT_TABLE_01
where name = 'CLIENT_COMMAND'
and process_order = -59;
col object_name for a30
col processing_status head STATUS for a6
col processing_state head STATE for a5
select distinct
object_schema,
object_name,
object_type,
object_tablespace,
process_order,
duplicate,
processing_status,
processing_state
from sys_import_table_01
where process_order > 0
and object_name is not null
order by object_schema, object_name
/
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:
$ impdp directory=exp_dir dumpfile=exp_user1_all_tab.dmp logfile=imp_exp_user1_tab sqlfile=tables.sql
Import: Release 11.2.0.3.0 - Production on Fri Apr 26 08:29:06 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Username: / as sysdba
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA Job "SYS"."SYS_SQL_FILE_FULL_01" successfully completed at 08:29:12
$ grep "CREATE USER" tables.sql
CREATE USER "USER1" IDENTIFIED BY VALUES 'S:270D559F9B97C05EA50F78507CD6EAC6AD63969E5E;BBE7786A5F9103'
Lot of datapump options explained here http://www.acehints.com/p/site-map.html
You need to search for OWNER_NAME.
cat -v dumpfile.dmp | grep -o '<OWNER_NAME>.*</OWNER_NAME>' | uniq -u
cat -v turn the dumpfile into visible text.
grep -o shows only the match so we don't see really long lines
uniq -u removes duplicate lines so you see less output.
This works pretty well, even on large dump files, and could be tweaked for usage in a script.
My solution (similar to KyleLanser's answer) (on a Unix box):
strings dumpfile.dmp | grep SCHEMA_LIST
In my case, based on Aldur's and slafs' answers I came up with this expression that should tell you just the name of the original schema:
cat -v file.dmp | grep 'SCHEMA_LIST' | uniq -u | grep -o -P '(?<=SCHEMAS\=).*(?=content)'
Tested for a DMP file from Oracle 19.8 version.