Exporting Database Links from a database in Oracle

Export PDB_SID to connect pdb as sys without password


read -p "Enter the PDB name: " ORACLE_PDB_SID && export ORACLE_PDB_SID && echo "PDB name set to: $ORACLE_PDB_SID"

Verify that the sqlplus / as sysdba is connecting to pdb

sqlplus / as sysdba
sho pdbs con_name

These commands will confirm that you're connected to the desired PDB.

Create dba directory for dblink export

sqlplus "/ as sysdba"
CREATE OR REPLACE DIRECTORY expdb_dir AS '&DBA_DIRECTORY_LOCATION';

Enable trace to troubleshoot incase of failure in expdp

alter system set events '10298 trace name context forever, level 32';

4. Export the db links



expdp "'/ as sysdba'" full=y directory=expdb_dir dumpfile=${ORACLE_PDB_SID}_export.dmp estimate=statistics include=DB_LINK:\"IN \(select db_link from dba_db_links where owner not like "'%/_AA'" ESCAPE "'/'"\)\" logfile=${ORACLE_PDB_SID}_export.log

Drop the dba directory created for db link

sqlplus "/  as sysdba"
drop directory expdb_dir;
Revert the trace if enable in the previous steps
alter system set events '10298 trace name context off';

Comments