How to use / as sysdba in pluggable database

expdporacle

I'm trying to make a export, usually I use userid=\"/ as sysdba\" syntax in Linux command line (I don't know sys password in my production environment.

How can I do this using pluggable database? I tried something like this: userid=\"/ as sysdba@mypdb_oracle_net\" but it does not work.

expdp userid=\"/ as sysdba@mypdb_oracle_net\" dumpfile=full_%U.exp logfile=full.log directory=teste full=y parallel=4 version=11.2.0

Export: Release 19.0.0.0.0 - Production on Tue Mar 10 11:18:06 2020
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.
UDE-00002: invalid username or password

Username:

Best Answer

First of all, to export from a PDB you shouldn't use SYS for that. It is way over-privileged. You should create a user in the PDB and use that user to connect to the database. You can use the privilege "exp_full_database" to grant the necessary privileges.

Next, you have to specify a connect string to go directly into the PDB (via the relevant service). It is "mypdb_oracle_net" in your example. However, when doing so, you must specify the password for SYS. You can't use OS authentication when doing this.

To solve your problem I would do something like this:

SQLPLUS / AS SYSDBA
ALTER SESSION SET CONTAINER=mypdb;
CREATE USER EXPORT_USER IDENTIFIED BY YOUR_PASSWORD;
GRANT CREATE SESSION TO EXPORT_USER;
GRANT exp_full_database TO EXPORT_USER;

EXPDP EXPORT_USER/YOUR_PASSWORD@mypdb_oracle_net dumpfi......