| Lesson 5 | National Character Sets |
| Objective | Choose a national character set for an Oracle 19c database. |
An Oracle 19c database uses two types of character sets: the database character set and the national character set. The database character set defines the encoding for data in CHAR, VARCHAR2, CLOB, and LONG columns, as well as identifiers and PL/SQL programs. The national character set is used exclusively for NCHAR, NVARCHAR2, and NCLOB columns, which are designed to store Unicode data for multilingual support or special characters not supported by the database character set.
Choosing a national character set is critical for applications requiring support for multiple languages or diverse character sets. This lesson outlines the steps to select an appropriate national character set for an Oracle 19c database.
NCHAR, NVARCHAR2, and NCLOB data types store Unicode data, enabling support for characters from multiple languages (e.g., Chinese, Arabic, or special symbols) that may not be covered by the database character set, such as AL32UTF8.NCHAR columns.AL32UTF8 in some contexts), suitable for applications with a mix of ASCII and multi-byte characters to optimize storage.Note: Since Oracle 12c, AL16UTF16 is the default national character set.
AL16UTF16, but you can choose UTF8 based on your needs.CREATE DATABASE statement. For example:
CREATE DATABASE your_database_name
...
NATIONAL CHARACTER SET AL16UTF16;
Replace AL16UTF16 with UTF8 if preferred.
NCHAR, NVARCHAR2, and NCLOB data maintains integrity across systems.To check the database and national character sets in Oracle 19c, query the NLS_DATABASE_PARAMETERS view. For example:
SELECT PARAMETER, VALUE
FROM NLS_DATABASE_PARAMETERS
WHERE PARAMETER IN ('NLS_CHARACTERSET', 'NLS_NCHAR_CHARACTERSET');
PARAMETER VALUE
------------------------ ----------------
NLS_CHARACTERSET AL32UTF8
NLS_NCHAR_CHARACTERSET AL16UTF16
This output shows a typical Oracle 19c configuration with AL32UTF8 as the database character set and AL16UTF16 as the national character set.
Changing the National Character Set: Modifying the national character set after database creation is complex, often requiring data export and re-import or database recreation. Choose carefully during initial setup to avoid future complications.
Single-Byte Limitations: Certain database elements (e.g., database names, instance names, filenames, rollback segment names, and keywords) must use single-byte characters, even if the national character set supports multi-byte characters. For NCHAR and NVARCHAR2, length specifications refer to the number of characters, not bytes, unlike CHAR and VARCHAR2.
AL16UTF16 (default) or UTF8 based on your application’s multilingual and storage needs.CREATE DATABASE statement to set the national character set during database creation.NLS_DATABASE_PARAMETERS and test thoroughly to ensure data integrity.By carefully choosing the national character set, you ensure your Oracle 19c database supports the multilingual and character encoding requirements of your application effectively.
Understanding how to choose a national character set prepares you to configure Oracle 19c databases for diverse applications. The next lesson will explore data conversion techniques for handling multilingual data across different character sets.