Close

21c My easiest upgrade ever

21c was released for Linux a little over a week ago. I downloaded the zip file, unzipped it, and created an empty container database.Then I wanted to upgrade one of my 19c DBs but I didn’t want to lose the 19 version. I wanted to have a before and after image to compare. This is where 21c made it particularly easy.

Prior to 21c I might have taken one of these options…

  • Upgrade my database and then restored the 19c from backup.
  • Cloned the 19c and then upgraded the clone to 21c.
  • Create an empty 21c PDB and then export/import interesting bits from 19c to 21c.
  • Upgrade the 19c to 21c and then create a new 19c container and empty PDB, then export/import from 21 back to 19.

With 21c I took a variation on option 2 – I simply created the pdb across a db link and the act of opening the clone inside the 21c container caused it to be upgraded. The entire clone/upgrade process used only SQL*PLUS. Once to source container to set up the PDB for cloning (creating a user for the dblink and putting the PDB in read only mode because it was just a test db, and not running in archive log mode.) Then a second SQL*PLUS session to create the link, do the create, and open.

Here was my the full setup in the 19c source container.

$ sqlplus sys@cdb193a as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Sat Aug 21 22:40:44 2021
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

Enter password:

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> alter session set container=pdb19a;

Session altered.

SQL> create user cloneuser identified by pa55w0rd;

User created.

SQL> grant CREATE PLUGGABLE DATABASE to cloneuser;

Grant succeeded.

SQL> grant create session to cloneuser;

Grant succeeded.

SQL> alter session set container=cdb$root;

Session altered.

SQL> alter pluggable database pdb19a open read only force;

Pluggable database altered.

SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

That’s all for the 19c DB, and now for the 21c work.

$ sqlplus sys@cdb21a as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Sat Aug 21 22:44:31 2021
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

Enter password:

Connected to:
Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0

SQL> create database link clone_link connect to cloneuser identified by pa55w0rd using 'pdb19a';

Database link created.

SQL> create pluggable database pdb21a from pdb19a@clone_link;

Pluggable database created.

SQL> alter pluggable database pdb21a open;

Pluggable database altered.

SQL> exit
Disconnected from Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0

It just doesn’t get much easier than that. My new 21c DB is ready to go. For “cleanup” I’ll reopen my 19c db in read write mode and probably drop the cloneuser since I don’t anticipate needing it again and it’ll be easy to recreate if I do.

21c is an “Innovation Release” so while it is fully supported it may not be something you want jump right into for production databases since its support lifetime will be limited compared to a “Long Term Release” version like 19c. But, if it has a feature or bug fix you need, getting there was very easy.