在12.1时,还要求PDB必须和CDB字符集相同,或者是CDB的子集,12.2已经支持在CDB中插入不同字符集的PDB。

但是alert log中可能仍会出现ORA-41401错误:

Errors in file /scratch/oradb/app/diag/rdbms/cdba/cdba1/trace/cdba1_q005_12770.trc:

ORA-41401: Define character set (873) does not match database character set (852)

这是Advance Queue的bug,BUG 22331316     – FIX RECURSIVE HSTDEF NLS STATE DURING MEDIUM CONTAINER SWITCH 。AQ处理时,从PDB跨到CDB时对字符集处理不当造成的。该bug的修复最终被包含在12.2.0.2中。

尽管Oracle已经支持在CDB中插入不同字符集的PDB,但是最佳实践仍然建议用户先做PDB数据库字符集转换,再plug-in。除了以上bug的原因,还因为这种不同字符集的PDB在plug-in时,oracle会对PDB的元数据进行字符集转换(以插入数据到CDB的v$视图中)。

这种plug-in时的字符集转换存在一定限制,并且可能会失败。

请参考:

Character Sets For CDB And PDB in 12.2 (Doc ID 2231602.1)

Note, there are some restrictions:
When a PDB character set is different from the CDB character set, there may be data truncation, if the column widths of CDB views and V$ views are not able to accommodate the PDB data that has expanded in length during the character set conversion.

As UTF8 and AL32UTF8 have different maximum character widths (three versus four bytes per character), the automatic change of UTF8 to AL32UTF8 during plug-in operation will change implicit maximum byte lengths of columns with character length semantics. This change may fail, if there are functional indexes, virtual columns, bitmap join indexes, domain indexes, partitioning keys, sub-partitioning keys, or cluster keys defined on those columns. The plug-in operation may also fail, if a character length semantics column is part of an index key, and the index key exceeds the size limit (around 70% of the index block size) after the character set change. You must make sure that all the offending objects are removed from a database before it is plugged into a CDB. You can recreate those offending objects in the database after the database is plugged into a CDB.