impdp does not accept two tables in an INCLUDE Command - oracle

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

Related

Oracle full EXPORT with exclude and NOT using par file

I need to do a full export of a 12.2 database. Recently we placed 2 tables in it with over 4 million records that will remain static. I'd like to eliminate them from the daily EXPDP as they have been archived offline.
This EXPDP is launched via a scheduled task and calls a series of batch files that have defined variables that are passed from batch file to batch file. This produces a series of log and archive files important in the larger scheme of things.
I do this without a .PAR file as the .PAR files does not seem to like any VARIABLE names defined in the batch files.
I can run this at the command prompt without issue, but if I call it via a batch I get an error
**
LRM-00111: no closing quote for value 'table:"LIK'
**
EXPDP *******/********#%dbname% FULL=Y exclude=statistics exclude=table:\"LIKE\'%_80\'\" DUMPFILE=%bckupdate%.dmp LOGFILE=%bckupdate%.log reuse_dumpfiles=yes
Any helpful hints on how to either use a variable name (as in %DBNAME%) in the PAR file or proper formatting for the batch file would be appreciated.
You can try this script expdp_powershell.ps1
For example
E:\upwork\stackoverflow\expdp_powershell>powershell ./expdp_powershell.ps1 -user_name system -user_password manager -connect_string test -exclude table:\"LIKE\'%_80\'\"
or
E:\upwork\stackoverflow\expdp_powershell>powershell ./expdp_powershell.ps1
Script expdp_powershell.ps1
param(
[string]$user_name = "system"
,
[string]$user_password = "manager"
,
[string]$connect_string = "TEST"
,
[string]$export_mode = "FULL=Y"
,
[string]$exclude = "table:\""LIKE \'%_80\'\"""
)
$date_time_log = Get-Date -Format "yyyyMMddHHmmss"
$DUMPFILE = "backup" + $date_time_log + ".dmp"
$LOGFILE = "backup_log" + $date_time_log + ".log"
$reuse_dumpfiles = "yes"
$DIRECTORY="DATA_PUMP_DIR"
echo $exclude
EXPDP $user_name/$user_password#$connect_string $export_mode exclude=statistics exclude=$exclude DIRECTORY=$DIRECTORY DUMPFILE=$DUMPFILE LOGFILE=$LOGFILE reuse_dumpfiles=$reuse_dumpfiles
For example output
E:\upwork\stackoverflow\expdp_powershell>powershell ./expdp_powershell.ps1 -user_name system -user_password manager -connect_string test -exclude table:\"LIKE\'%_80\'\"
table:\"LIKE \'%_80\'\"
Export: Release 11.2.0.4.0 - Production on Sat Jan 9 12:44:10 2021
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYSTEM"."SYS_EXPORT_FULL_01": system/********#TEST FULL=Y exclude=statistics exclude=table:"LIKE \'%_80\'" DIRECTORY=DATA_PUMP_DIR DUMPFILE=backup20210109124410.dmp LOGFILE=ba
ckup_log20210109124410.log reuse_dumpfiles=yes
Estimate in progress using BLOCKS method...
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 363.1 MB
Processing object type DATABASE_EXPORT/TABLESPACE
Processing object type DATABASE_EXPORT/PROFILE
Processing object type DATABASE_EXPORT/SYS_USER/USER
Processing object type DATABASE_EXPORT/SCHEMA/USER
Processing object type DATABASE_EXPORT/ROLE
Processing object type DATABASE_EXPORT/GRANT/SYSTEM_GRANT/PROC_SYSTEM_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/GRANT/SYSTEM_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/ROLE_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/DEFAULT_ROLE
Processing object type DATABASE_EXPORT/SCHEMA/TABLESPACE_QUOTA
Processing object type DATABASE_EXPORT/RESOURCE_COST
Processing object type DATABASE_EXPORT/TRUSTED_DB_LINK
Processing object type DATABASE_EXPORT/SCHEMA/SEQUENCE/SEQUENCE

ORA-01919: role 'RESTRICTED_ROLE1' does not exist

I am getting this error while trying to import with impdp
expdp system/system schema=ieulive directory=data_pump dumpfile=IEULIVE2.DMP logfile=exp.log
at export, all good
imp system/system remap_schema=ieulive:ieu1 directory=dir1 dumpfile=IEULIVE2.DMP logfile=imp.log
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
ORA-39083: Object type ROLE_GRANT failed to create with error:
ORA-01919: role 'RESTRICTED_ROLE1' does not exist
Failing sql is:
GRANT "RESTRICTED_ROLE1" TO "IEULIVE" WITH ADMIN OPTION
.
.
.
.
also tried with
expdp ieulive/ieulive directory=data_pump dumpfile=IEULIVE2.DMP logfile=exp.log
impdp ieu1/ieu1 directory=dir1 dumpfile=IEULIVE2.DMP logfile=imp.log
not sure what the difference between two methods, but anyway I got the same result
Help Appreciated.
#scapy answered the question in the question comment, I bosted the answer to accept as solution.
create role restricted_role1;
then import.

Oracle 12 import - imp command

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

Why do I get ORA-39001: invalid argument value when I try to impdp in Oracle 12c?

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

Error while importing a DUMP file

SQL> impdp Fossil_ARSENAL/Fossil_ARSENAL#ARIF Dumpfile=FOSSIL_PLM_AUG_11.dmp transfo
rm=SEGMENT_ATTRIBUTES:N:INDEX REMAP_TABLESPACE=FOSSIL_PLM:Fossil_ARSENAL REMAP_SCH
EMA=FOSSIL_PLM:Fossil_ARSENAL LOGFILE=dp.log;
Error Msg Below:
SP2-0734: unknown command beginning "impdp Foss..." - rest of line ignored.
USERNAME : Fossil_ARSENAL
PASSWORD : Fossil_ARSENAL
DataBase Name : ARIF
Dumpfile NAme : FOSSIL_PLM_AUG_11.dmp
TableSpace Name : Fossil_ARSENAL
impdp is a separate executable; you call it from your operating system's command line, not from within SQL*Plus. The documentation describes expdp and impdp as command-line clients. The command looks reasonable, apart from noot seeming to have a directory argument; you're just issuing it in the wrong place.

Resources