Friday, January 12, 2018

EXPDP AND IMPDP Tricks

Have you ever been a situation that you needed to refresh a schema on DEV using data from PROD? This is a common scenario for a DBA.

Case1: Different SCHEMA and/or TABLESPACE

In my years of experience it is common to see that PROD and DEV environments does not have the same structure in terms of server capacity, file structure, schema and even tablespaces.

Let's say we have target DB called TDB and a source DB called SDB (pretty cool, i know right!). Our schema are TSCHEMA and SSCHEMA respectively and TSPACE and SSPACE for the tablespaces.

Step 1

In your source DB do this 

expdp directory=DATA_PUMP_DIR schemas=SSCHEMA dumpfile=expSSCHEMA.dmp logfile=expSSCHEMA.log 

(if you are in a *nix box, create this in a expdpSSCHEMA.sh so you would only have to key in the user and password. It is efficient instead of looking at "Burlesin Pages" all the time).


Step 2

Transfer expSSCHEMA.dmp to the target server.

Step 3

Once it is there do this

impdp directory=DUMPDIR 
remap_schema=expSSCHEMA:expTSCHEMA 
REMAP_TABLESPACE=SSPACE:TSSPACE
TABLE_EXISTS_ACTION=TRUNCATE 
dumpfile=expSSCHEMA.dmp
logfile=impSSCHEMA.log 

(if you are in a *nix box, create this in a expdpSSCHEMA.sh so you would only have to key in the user and password. It is efficient instead of looking at "Burlesin Pages" all the time).

Your Done.

Tuesday, January 9, 2018

ORA-39065: unexpected master process exception in DISPATCH

During expdp I received an error. See below


Export: Release 11.2.0.4.0 - Production on Tue Jan 9 00:28:47 2018

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
ORA-39006: internal error
ORA-39065: unexpected master process exception in DISPATCH
ORA-01403: no data found

ORA-39097: Data Pump job encountered unexpected error 100

To Validate the Problem I ran

SQL> select count(*) from metanametrans$;
  COUNT(*)
----------
         0

It should have more values than that!
Solution
@$ORACLE_HOME/rdbms/admin/catmet2.sql
@$ORACLE_HOME/rdbms/admin/utlrp.sql


Then try again.