Source :
SQL> alter session set container=OGGDB1PDB;
Session altered.
SQL> select username from dba_users where oracle_maintained='N';
USERNAME
--------------------------------------------------------------------------------
PDBADMIN
HR
SQL> select table_name from dba_tables where owner='HR';
TABLE_NAME
--------------------------------------------------------------------------------
REGIONS
LOCATIONS
DEPARTMENTS
JOBS
EMPLOYEES
JOB_HISTORY
COUNTRIES
7 rows selected.
SQL> select table_name,num_rows from dba_tables where owner='HR';
TABLE_NAME NUM_ROWS
------------------- ----------
REGIONS 4
LOCATIONS 23
DEPARTMENTS 27
JOBS 19
EMPLOYEES 107
JOB_HISTORY 10
COUNTRIES 25
7 rows selected.
SQL> select directory_name from dba_directories;
DIRECTORY_NAME
--------------------------------------------------------------------------------
XMLDIR
XSDDIR
ORA_DBMS_FCP_LOGDIR
ORA_DBMS_FCP_ADMINDIR
OPATCH_INST_DIR
ORACLE_OCM_CONFIG_DIR
DATA_PUMP_DIR
ORACLE_OCM_CONFIG_DIR2
OPATCH_SCRIPT_DIR
OPATCH_LOG_DIR
ORACLE_BASE
ORACLE_HOME
1* select directory_name,directory_path from dba_directories
SQL> /
DIRECTORY_NAME DIRECTORY_PATH
----------------- ---------------------------------------------------------------------------------
XMLDIR /u01/app/oracle/product/12.2.0.1/rdbms/xml
XSDDIR /u01/app/oracle/product/12.2.0.1/rdbms/xml/schema
ORA_DBMS_FCP_LOGDIR /u01/app/oracle/product/12.2.0.1/cfgtoollogs
ORA_DBMS_FCP_ADMINDIR /u01/app/oracle/product/12.2.0.1/rdbms/admin
OPATCH_INST_DIR /u01/app/oracle/product/12.2.0.1/OPatch
ORACLE_OCM_CONFIG_DIR /u01/app/oracle/product/12.2.0.1/ccr/state
DATA_PUMP_DIR /u01/app/oracle/admin/oggdb1/dpdump/EE0955F9C4AB14D0E0536638
ORACLE_OCM_CONFIG_DIR2 /u01/app/oracle/product/12.2.0.1/ccr/state
OPATCH_SCRIPT_DIR /u01/app/oracle/product/12.2.0.1/QOpatch
OPATCH_LOG_DIR /u01/app/oracle/product/12.2.0.1/rdbms/log
ORACLE_BASE /u01/app/oracle
ORACLE_HOME /u01/app/oracle/product/12.2.0.1
OGGDB1PDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ggate1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = oggdb1pdb)
)
)
expdp sys/oracle@OGGDB1PDB directory=DATA_PUMP_DIR dumpfile=hr_employees.dmp tables=hr.employees logfile=employees.log
Export: Release 12.2.0.1.0 - Production on Fri Dec 2 00:02:19 2022
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
UDE-28009: operation generated ORACLE error 28009
ORA-28009: connection as SYS should be as SYSDBA or SYSOPER
Username: sys/oracle@OGGDB1PDB as sysdba
Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
Starting "SYS"."SYS_EXPORT_TABLE_01": sys/********@OGGDB1PDB AS SYSDBA directory=DATA_PUMP_DIR dumpfile=hr_employees.dmp tables=hr.employees logfile=employees.log
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/COMMENT
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/TRIGGER
. . exported "HR"."EMPLOYEES" 17.08 KB 107 rows
Master table "SYS"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_TABLE_01 is:
/u01/app/oracle/admin/oggdb1/dpdump/EE0955F9C4AB14D0E0536638A8C0EB50/hr_employees.dmp
Job "SYS"."SYS_EXPORT_TABLE_01" successfully completed at Fri Dec 2 00:03:28 2022 elapsed 0 00:00:37
Target :
[oracle@ggate1 ~]$ . oraenv
ORACLE_SID = [oggdb1] ? tgtcdb
The Oracle base remains unchanged with value /u01/app/oracle
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ---------------------- ---------- ----------
2 PDB$SEED READ ONLY NO
3 TARGETPDB READ WRITE NO
SQL> alter session set container=TARGETPDB;
Session altered.
1* select directory_name,directory_path from dba_directories
SQL> /
DIRECTORY_NAME DIRECTORY_PATH
--------------------------------------- -------------------------------------------------------------------------
XMLDIR /u01/app/oracle/product/12.2.0.1/rdbms/xml
XSDDIR /u01/app/oracle/product/12.2.0.1/rdbms/xml/schema
ORA_DBMS_FCP_LOGDIR /u01/app/oracle/product/12.2.0.1/cfgtoollogs
ORA_DBMS_FCP_ADMINDIR /u01/app/oracle/product/12.2.0.1/rdbms/admin
OPATCH_INST_DIR /u01/app/oracle/product/12.2.0.1/OPatch
ORACLE_OCM_CONFIG_DIR /u01/app/oracle/product/12.2.0.1/ccr/state
DATA_PUMP_DIR /u01/app/oracle/admin/tgtcdb/dpdump/EE1DA335F2064F71E0536638A8C034E1
ORACLE_OCM_CONFIG_DIR2 /u01/app/oracle/product/12.2.0.1/ccr/state
OPATCH_SCRIPT_DIR /u01/app/oracle/product/12.2.0.1/QOpatch
OPATCH_LOG_DIR /u01/app/oracle/product/12.2.0.1/rdbms/log
ORACLE_BASE /u01/app/oracle
ORACLE_HOME /u01/app/oracle/product/12.2.0.1
SQL> select table_name,num_rows from dba_tables where owner='HR';
TABLE_NAME NUM_ROWS
----------------- -----------------
REGIONS 4
LOCATIONS 23
DEPARTMENTS 27
JOBS 19
EMPLOYEES 107
JOB_HISTORY 10
COUNTRIES 25
7 rows selected.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- -------------------------- ---------- ----------
3 TARGETPDB READ WRITE NO
SQL>
TARGETPDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ggate1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = TARGETPDB)
)
)
impdp sys/oracle@TARGETPDB directory=DATA_PUMP_DIR dumpfile=hr_employees.dmp tables=hr.employees logfile=employees_imp.log table_exists_action=replace
[oracle@ggate1 admin]$ impdp sys/oracle@TARGETPDB directory=DATA_PUMP_DIR dumpfile=hr_employees.dmp tables=hr.employees logfile=employees_imp.log table_exists_action=replace
Import: Release 12.2.0.1.0 - Production on Fri Dec 2 00:09:15 2022
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
UDI-28009: operation generated ORACLE error 28009
ORA-28009: connection as SYS should be as SYSDBA or SYSOPER
Username: sys/oracle@TARGETPDB as sysdba
Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
Master table "SYS"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "SYS"."SYS_IMPORT_TABLE_01": sys/********@TARGETPDB AS SYSDBA directory=DATA_PUMP_DIR dumpfile=hr_employees.dmp tables=hr.employees logfile=employees_imp.log table_exists_action=replace
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "HR"."EMPLOYEES" 17.08 KB 107 rows
Processing object type TABLE_EXPORT/TABLE/COMMENT
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/TRIGGER
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
Job "SYS"."SYS_IMPORT_TABLE_01" successfully completed at Fri Dec 2 00:10:14 2022 elapsed 0 00:00:32