Friday, October 17, 2014

Oracle: How to insert chinese characters into Oracle database

So, I have a Oracle 11.2.0.4 db running on a windows server with WE8MSWIN1252 Characterset
and AL16UTF16 NChar characterset.





NLS_Lang on my client is defined as "American.America.WE8MSWIN1252"




My table is defined as below

Create table t2 ( name Varchar2(100), local_name NVarchar2(100))

A simple Insert like below, resulted in all junk character

Insert into t2 values ('Ramesh', '拉梅什')





So, I had to do 2 things. First, Add a new environment variable called "ORA_NCHAR_LITERAL_REPLACE" and set it to TRUE





Then, Restart my client, in my case its Toad.

Prefix Asian characters with N

Insert into t2 values ('Ramesh', N'拉梅什')






Once I figured out how to make the asian characters into Oracle, second step was to import an Excel sheet with 8000 names to the db.

I tried SQL Loader, Import tool in Toad, and all resulted in junk characters.

So my only solution was to follow a manual approach. I had to generate an insert statement from Excel and run those Insert's from Toad.

No comments:

Post a Comment