Can you select a PDB’s character set?

Can you select a PDB's character set?Since Oracle Database 12.2.0.1 a Multitenant container database can host PDBs with different character sets. This was a huge restriction in Oracle Database 12.1., at least outside the US and Canada. Here in Germany alone you may find plenty of different database character sets, for instance WE8ISO8859P1, WE8ISO8859P9, WE8ISO8859P15, WE8MSWIN1252, maybe still some old WE8DEC – and of course the unicode ones UTF8 and AL32UTF8. But the question is: Can you select a PDB’s character set when you provision a new PDB?

Mixing PDB character sets in Oracle Database 12.2.

One of the limiting restrictions in Oracle 12.1 Multitenant got lifted with Oracle 12.2: You can have PDBs with different character sets in one container database deployment. The requirement: You must create the container database with  character set AL32UTF8. This means the database character set in CDB$ROOT and therefore as well in PDB$SEED will be AL32UTF8. Once this is the case you can plugin PDBs with all sorts of character sets.

But when you provision a new PDB it will be provisioned as a clone of PDB$SEED – and of course will have the character set AL32UTF8 as well. There may be very rare situations where you want a fresh PDB with a different character set.

Changing the PDB’s character set

Can you select a PDB's character set?The tool to change a PDB’s character set is the Data Migration Assistant for Unicode (DMU). DMU is installed in all Oracle releases since Oracle 11.2.0.4 by default. Just check the $ORACLE_HOME/dmu subdirectory and start the DMU with sh dmu.sh. And find more information about the DMU here: DMU – Tips and Tricks.

But as the name indicates, the DMU is meant to change a database’s (or PDB’s) character set to Unicode. There is a option to use DMU to change to another character set with csrepair.plb. But this does not help here as one of the requirements to use csrepair.plb says: “Only repairing from single-byte to single-byte character sets or multi-byte to multi-byte character sets is allowed as no conversion of CLOB data will be attempted.”

Furthermore the old (and now unsupported) ALTER DATABASE CHARACTER SET INTERNAL_USE <new NLS_CHARACTERSET> seems to work fine at first sight, but actually doesn’t change any CLOB data. And you’ll have plenty of CLOB data in the PDB’s dictionary. Don’t use it. Your PDB won’t be in healthy state afterwards anymore.

Basically this means you can’t change a PDB’s character set from a non-unicode character set to a unicode character set which is the requirement for mixing different character sets within a single Multitenant deployment.

Potential Workaround?

Actually the only potential workaround I can think of is:

Summary

You can’t select a PDB’s character set during creation. It will always provisioned as a clone of PDB$SEED and therefore have a multi-byte character set (AL32UTF8) when you have a CDB environment being able to host different character sets in PDBs.

And as you can’t change a PDB’s character set from single-byte to multi-byte afterwards either your only workaround is to provide your own “seed” PDBs with the character set of your choice and provision new PDBs as a clone of it.

Thanks (as always) to Sergiusz Wolicki for helping me with my questions!

–Mike

2 thoughts on “Can you select a PDB’s character set?

  1. Mike:
    Thanks a lot. I just want to ask one question, if CDB$ROOT is AL32UTF8, can you plugged in a PDB with single character character set like US7ASCII?

    Thanks.

    • Hi Eric,

      had to try it out 😉

      SQL> select * from pdb_plug_in_violations where cause=’PDB not Unicode’;

      TIME NAME CAUSE TYPE ERROR_NUMBER LINE MESSAGE STATUS ACTION CON_ID
      ————————————————————————— ——————– —————————————————————- ——— ———— ———- —————————————- ——— —————————————- ———-
      23-OCT-17 03.42.37.168422 PM US7 PDB not Unicode WARNING 0 1 Character set mismatch: PDB character se PENDING Oracle recommends using Unicode (AL32UTF 3
      t US7ASCII. CDB character set AL32UTF8. 8) character set for the database. Consi
      der migrating the database to Unicode.

      Yes, works – but you’ll receive a “WARNING” in PDB_PLUG_IN_VIOLATIONS.
      Warnings don’t prevent PDBs to be opened unrestricted.

      Cheers
      Mike

Leave a Reply

Your email address will not be published. Required fields are marked *