1

I have added the HR data base to oracle 19c, but the thing is, every time I execute the sqldeveloper, it says the database is not open, so then I go to cmd and execute the following scripts, but is there any way to keep it always open? I don't want to go to cmd all the time.

sqlplus / as sysdba
show con_name;
ALTER SESSION SET CONTAINER = orclpdb;
COLUMN name FORMAT a20;
SELECT name, open_mode from v$pdbs;
ALTER PLUGGABLE DATABASE open;
ALTER USER hr IDENTIFIED BY hr ACCOUNT UNLOCK;
conn hr/hr@orclpdb;
SHOW USER;'
Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55
cesalomx
  • 25
  • 7
  • What is "HR data base"? HR is usually the optionally created sample schema at any data base (e.g. PDB). – 0xdb Apr 20 '20 at 11:51

1 Answers1

2

Since 12.1.0.2 the new clause SAVE STATE was added to the statement ALTER PLUGGABLE DATABASE.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           READ WRITE NO
         4 PDB2                           MOUNTED

SQL> shutdown immediate

After restart all PDB's remain closed:

SQL> startup
SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           MOUNTED
         4 PDB2                           MOUNTED

Preserve thе last state of PDB (all PDB's with ALL instead of PDB name):

SQL> alter pluggable database pdb1 open;
SQL> alter pluggable database pdb1 save state;

Now, after restart the desired PDB will be opened automatically:

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           READ WRITE NO
         4 PDB2                           MOUNTED
0xdb
  • 3,539
  • 1
  • 21
  • 37
  • I did tried to saved the state, and I got the following response and I do not know what I have to do to fix it: ORA-65118 - operation affecting a pluggable database cannot be performed from another pluggable database. – cesalomx Apr 19 '20 at 00:25
  • @cesalomx _cannot be performed from **another pluggable database**_, you must be connected on CDB. – 0xdb Apr 19 '20 at 00:30