2

I have to confess I have no idea about this pluggable database thing. I have experience in PostgresSQL, MySQL, SQL Server, but Oracle has me defeated.

I have Oracle 18c running in a Docker image. I want to create a pluggable database called bookshop. Following some instructions, I ran the following:

CREATE PLUGGABLE DATABASE bookshop ADMIN USER pdb_adm IDENTIFIED BY Oradoc_db1
    file_name_convert=('/opt/oracle/oradata/XE/pdbseed','/opt/oracle/oradata/XE/BOOKSHOP');

Next in the instructions, I run:

ALTER PLUGGABLE DATABASE xepdb2 OPEN READ WRITE;

except that I can’t. I get the message:

ORA-01031: insufficient privileges.

I then try:

DROP PLUGGABLE DATABASE bookshop;

and I get the same message.

When I try:

SELECT vp.name, vp.open_mode
FROM v$pdbs vp;

I get

NAME OPEN_MODE
PDB$SEED READ ONLY
XEPDB1 READ WRITE
XEPDB2 READ WRITE
BOOKSHOP MOUNTED

And finally, when I try to work out who I am:

SELECT user FROM dual;

I get SYSTEM.

At this point I have no idea how to get control over this pluggable database. Do I need to switch to another user? How?

1 Answer 1

1

First, try connecting to your container database as SYS instead of SYSTEM. SYSTEM is a template DBA account, but SYS (or any user with SYSDBA privileges, which effectively makes them SYS) is more powerful and must be used for some specific commands.

connect sys as sysdba;

Next, your xepdb2 database is already open in "READ WRITE" mode, so you don't need to open it again.

Last, open your BOOKSHOP database with:

alter pluggable database bookshop open;

Conceptually, think of pluggable databases the same way you would think of a virtual machine in relation to a bare metal server. It's a logical construct that allows you to consolidate and share certain resources on the database server. The container database (CDB) is somewhat like your hypervisor: you generally don't mess with it except to create pluggable databases (PDBs), or perform certain system-level activities like backup and recovery. All of your application schemas and constructs go in the PDBs.

1
  • Logging in as sys did the job. I had to learn about DROP PLUGGABLE DATABASE bookshop INCLUDING DATAFILES; to finish the job, and now I can start again. Thanks for your help.
    – Manngo
    Mar 13, 2022 at 22:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.