Reputation: 47
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;'
Upvotes: 1
Views: 347
Reputation: 3697
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
Upvotes: 3