Sometimes exported schema list is not available while doing import activity, and the DBA who performed export activity is not
available may be due to different geographical work location or DBA forgot to update the same in eMail or other communication channel.
In this article we will see how to extract what schemas have been exported / imported from expdp/impdp logfiles.
Command:
$cat expdp_full_ORCL.log|grep -i exported|cut -d “.” -f3|cut -d ” ” -f3|sort|uniq |
Output(schema names)
===========
"APPSADM"
"DZET"
"LEOW"
"KDOW"
"ODBCFZ"
"PVBOUSER"
"QUARTZ"
"SYS"
"SYSTEM"
for example dumpfile content is as below .FileName: expdp_full_ORCL.log
==================================================================================================
$cat expdp_full_ORCL.log
Processing object type DATABASE_EXPORT/PRE_SYSTEM_IMPCALLOUT/MARKER
Processing object type DATABASE_EXPORT/PRE_INSTANCE_IMPCALLOUT/MARKER
Processing object type DATABASE_EXPORT/EARLY_OPTIONS/VIEWS_AS_TABLES/TABLE_DATA
Processing object type DATABASE_EXPORT/NORMAL_OPTIONS/VIEWS_AS_TABLES/TABLE_DATA
Processing object type DATABASE_EXPORT/NORMAL_OPTIONS/TABLE_DATA
. . exported "KDOW"."PARAM" 3.571 KB 23 rows
. . exported "DZET"."HINT_TABLE" 9.992 KB 97 rows
. . exported "DZET"."SUMDET" 12.467 KB 136 rows
===================================================================================================
Complete command
===================
$cat expdp_full_ORCL.log|grep -i exported|cut -d "." -f3|cut -d " " -f3|sort|uniq
Let us see how we extracted only schemas in the final output step by step
Step 1) cat expdp_full_ORCL.log|grep -i exported
|
From the logfile all the lines with exported key word will be extracted.
$cat expdp_full_ORCL.log|grep -i exported
. . exported "KDOW"."PARAM" 3.571 KB 23 rows
. . exported "DZET"."HINT_TABLE" 9.992 KB 97 rows
. . exported "DZET"."SUMDET" 12.467 KB 136 rows
$
Step 2) cat expdp_full_ORCL.log|grep -i exported|cut -d “.” -f3
|
From the exported line we can cut the 3rd fileld which is schema/user name in that database.
$cat expdp_full_ORCL.log|grep -i exported|cut -d "." -f3
exported "KDOW"
exported "DZET"
exported "DZET"
Step 3)
cat expdp_full_ORCL.log|grep -i exported|cut -d “.” -f3|cut -d ” ” -f3
|
Again 3rd filed will be displayed.
Note : there is space before "exported" , hence cut -d " " -f3
In the first cut command filed separator is dot (.).
In the second cut command filed separator is space (" ").
$cat expdp_full_ORCL.log|grep -i exported|cut -d "." -f3|cut -d " " -f3
"KDOW"
"DZET"
"DZET"
$
Step 4) Sorting will be done in the ascending order by sort command
|
$cat expdp_full_ORCL.log|grep -i exported|cut -d "." -f3|cut -d " " -f3|sort
"DZET"
"DZET"
"KDOW"
Step 5)uniq command removes duplicate entries , it works like a distinct command in SQL queries.
|
$cat expdp_full_ORCL.log|grep -i exported|cut -d "." -f3|cut -d " " -f3|sort
"DZET"
"KDOW"
$
For import activity verification also same commands to complete the task that is given below.
what schemas imported? |
$cat Impdp_ORCL_to_ORCP.log|grep -i imported|cut -d "." -f3|cut -d " " -f3|sort|uniq
"DZET"
"LEOW"
"KDOW"
"ODBCFZ"
"PVBOUSER"
"QUARTZ"
These commands are useful to verify the activiy has been performed correctly or not before we handover the environment to application team.