Skip to content

Instantly share code, notes, and snippets.

@deterralba
Created May 30, 2022 08:48
Show Gist options
  • Save deterralba/b228218c71b6b8059e8375034160b3f8 to your computer and use it in GitHub Desktop.
Save deterralba/b228218c71b6b8059e8375034160b3f8 to your computer and use it in GitHub Desktop.
oracle impdp: Value for EXCLUDE is badly formed

Problem

In a bash shell or script, you want to exclude a table from you oracle import using

EXCLUDE=TABLE:"IN ('MY_TABLE')"

But you get the following error

ORA-39001: invalid argument value
ORA-39071: Value for EXCLUDE is badly formed.
ORA-00920: invalid relational operator

Solution

Because you are in a shell, the quotes needs to be escaped:

impdp USER/****@DB1 directory=import_dir dumpfile=dump.dpdmp exclude=TABLE:\"NOT IN \(\'MY_TABLE\'\)\"

BONUS: python integration

If you want to run this command for a python script, you just have to use a raw-string:

command = r''' impdp USER/****@DB1 directory=import_dir dumpfile=dump.dpdmp exclude=TABLE:\"NOT IN \(\'MY_TABLE\'\)\" '''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment