Wini
Wini

Reputation: 25

How to store Unicode characters in Oracle?

I have an Oracle database. I tried to stored Arabic characters in a table, but it leads to reverse question marks in the database. The datatype of the column is VARCHAR2.

I used the following query to check the characterset.

SELECT * FROM NLS_DATABASE_PARAMETERS 

The characterset is WE8MSWIN1252. How can I handle it?

SQL> select * from nls_database_parameters ORDER BY PARAMETER;

      PARAMETER                      VALUE
      ------------------------------ ---------------------------------------
      NLS_CALENDAR                   GREGORIAN
      NLS_CHARACTERSET               WE8MSWIN1252
      NLS_COMP                       BINARY
      NLS_CURRENCY                   $
      NLS_DATE_FORMAT                DD-MON-RR
      NLS_DATE_LANGUAGE              AMERICAN
      NLS_DUAL_CURRENCY              $
      NLS_ISO_CURRENCY               AMERICA
      NLS_LANGUAGE                   AMERICAN
      NLS_LENGTH_SEMANTICS           BYTE
      NLS_NCHAR_CHARACTERSET         AL16UTF16

      PARAMETER                      VALUE
      ----------------------- ----------------------------------------
      NLS_NCHAR_CONV_EXCP            FALSE
      NLS_NUMERIC_CHARACTERS         .,
      NLS_RDBMS_VERSION              11.2.0.3.0
      NLS_SORT                       BINARY
      NLS_TERRITORY                  AMERICA
      NLS_TIMESTAMP_FORMAT           DD-MON-RR HH.MI.SSXFF AM
      NLS_TIMESTAMP_TZ_FORMAT        DD-MON-RR HH.MI.SSXFF AM TZR
      NLS_TIME_FORMAT                HH.MI.SSXFF AM
      NLS_TIME_TZ_FORMAT             HH.MI.SSXFF AM TZR

      20 rows selected.

Upvotes: 1

Views: 3793

Answers (2)

Codo
Codo

Reputation: 78795

Do yourself (and all other people working on the database) a favor and upgrade your database to use AL32UTF8 as the default database character set. It's a bigger one time effort than using NVARCHAR2 for a few selected columns but it saves a lot of work and trouble in the future.

See Character Set Migration for instructions.

Upvotes: 2

Laurenz Albe
Laurenz Albe

Reputation: 246063

You cannot store arabic characters in the character set WE8MSWIN1252.

But there is an escape route: the national character set.
If you define the column as NVARCHAR2 instead of VARCHAR2, any character can be stored in it.

Upvotes: 2

Related Questions