Skip to Main Content
  • Questions
  • how to export PDB tables with SYS user with out password on DB 19.18 version

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Kalyan.

Asked: March 29, 2023 - 6:42 am UTC

Last updated: May 16, 2023 - 3:10 am UTC

Version: 19.18

Viewed 10K+ times! This question is

You Asked

how to export PDB tables with SYS user with out password.

I want to export tables under a specific schema using SYS user with out password.




I have created a par file as below:

directory=EXPDP_REFRESH
dumpfile=CLIENT_TABLE.DMP
schemas=TEST
CONTENT=ALL
NOLOGFILE=Y
include=table:"in('ABCD','DEFG','HIJK','LMNO')"

$export ORACLE_PDB_SID=<PDB_NAME>;
$expdp \"/ as sysdba\" parfile=client_export.par

Above script works fine at 19.15 version but does not work on 19.18 DB version.

please provide any alternate solution.

and Connor said...

That's because its undocumented and unsupported to my knowledge.

As per Mike's post, https://mikedietrichde.com/2020/05/07/can-you-connect-as-sysdba-without-password-into-a-pdb-directly/, there was always going to be a risk that you would end up with a change or issues as time went on.

Also, you're not meant to dump as SYS as per the best practices

https://www.oracle.com/a/ocom/docs/oracle-data-pump-best-practices.pdf

But having said that - it still works fine for me in 19.18, so its not a version thing - you must have changed a configuration somewhere

[oracle@db19 ~]$ export ORACLE_PDB_SID=PDB1
[oracle@db19 ~]$ expdp \"/ as sysdba\" tables=scott.emp

Export: Release 19.0.0.0.0 - Production on Wed Apr 5 21:38:00 2023
Version 19.18.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Starting "SYS"."SYS_EXPORT_TABLE_01":  "/******** AS SYSDBA" tables=scott.emp 
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/CONSTRAINT/CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
. . exported "SCOTT"."EMP"                               8.773 KB      14 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/db192/dpdump/823B94BC877B18D5E053B601A8C0020F/expdat.dmp
Job "SYS"."SYS_EXPORT_TABLE_01" successfully completed at Wed Apr 5 21:38:20 2023 elapsed 0 00:00:20

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Why not run data pump as sys?

Yong Huang, May 12, 2023 - 8:18 pm UTC

The warning "DO NOT INVOKE EXPORT USING SYS as SYSDBA" in the "Oracle Data Pump Best Practices" article is well known. But I've never seen an article that talks about specific pitfalls or any negative impact if we do run data pump as sys. What could they be? I can't imagine these potential problems, if any, are intentionally kept undocumented. On the other hand, running it as sys gives us convenience of not worrying about missing grants on sys-owned objects. (Data pump could be enhanced to give us a warning when such grants exist. See https://forums.oracle.com/ords/apexds/post/database-idea-add-a-warning-about-sys-owned-objects-not-exp-5164 )
Connor McDonald
May 16, 2023 - 3:10 am UTC

DataPump temporarily creates objects in the database in order to let it run an export or import. Building these as SYS has been known to create issues, and of course, if it fails, you now have stuff littering your SYS schema which is potentially a sleeper problem for the down the line upgrades etc.

For example, a full import will potentially run much slower if you do it as SYS.

(But I do agree with the issue of missing SYS grants)

More to Explore

Data Pump

All of the database utilities including Data Pump are explained in the Utilities guide.