How to include roles and grants into datapump export

For sure one way to do it, would be this one:

Prepare the parameters file first:

FULL=YES
INCLUDE=SCHEMA:"IN (SELECT 'PUBLIC' FROM DUAL UNION SELECT username FROM dba_users WHERE username in ('DB_USER1','DB_USER2'))"
INCLUDE=PUBLIC_SYNONYM/SYNONYM:"IN (SELECT synonym_name FROM dba_synonyms WHERE owner = 'PUBLIC' AND table_owner in ('DB_USER1','DB_USER2'))"
DIRECTORY=DATA_PUMP_DIR
DUMPFILE=orcl_expdp.dmp
LOGFILE=orcl_expdp.log
INCLUDE=ROLE:"IN (select role from dba_roles where role in (select grantee from dba_tab_privs where grantor in ('DB_USER1','DB_USER2')))" 

And the command to run would be this one:

expdp  \'/ as sysdba\' DIRECTORY=DATA_PUMP_DIR parfile= orcl_full.par
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.