i have a quick question here, that i would like to know the difference between NLS_NCHAR_CHARACTERSET and NLS_CHARACTERSET setting in oracle ??
from my understanding NLS_NCHAR_CHARACTERSET is for NVARCHAR data types and for NLS_CHARACTERSET would be for VARCHAR2 data types.
i tried to test this on my development server which my current settings for CHARACTERSET is as the following :-
PARAMETER VALUE
------------------------------ ----------------------------------------
NLS_NCHAR_CHARACTERSET AL16UTF16
NLS_NUMERIC_CHARACTERS .,
NLS_CHARACTERSET US7ASCII
Then i inserted some Chinese character values into the database. i inserted the characters into a table called data_ and updated the column for ADDRESS and ADDRESS_2 which are VARCHAR2 columns. By right from my understanding with the current setting for NLS_CHARACTERSET US7ASCII , chinese characters should not be supported but it is still showing in the database ?? does NLS_NCHAR_CHARACTERSET take precedence over this ??
Thank You.
In general all your points are correct.
NLS_NCHAR_CHARACTERSET
defines the character set forNVARCHAR2
, et. al. columns whereasNLS_CHARACTERSET
is used forVARCHAR2
.The reason is, your database character set and your client character set (i.e. see
NLS_LANG
value) are bothUS7ASCII
. Your database usesUS7ASCII
and it "thinks" also the client sends data usingUS7ASCII
. Thus it does not make any conversion of the strings, the data are transferred one-to-one from client to server and vice versa.Due to that fact you can use characters which are actually not supported by
US7ASCII
. Be aware, in case your client uses a different character set (e.g. when you use ODP.NET Managed Driver in an Windows application) the data will be rubbish! Also if you would consider a database character set migration you have the same issue.Another note: I don't think you would get the same behavior with other character sets, e.g. if your database and your client both would use
WE8ISO8859P1
for example. Also be aware that you actually have wrong configuration. Your database uses character setUS7ASCII
, yourNLS_LANG
value is alsoUS7ASCII
(most likely it is not set at all and Oracle defaults it toUS7ASCII
) but the real character set of SQL*Plus, resp. yourcmd.exe
terminal is most likely CP950 or CP936.If you like to set everything properly you can either set your environment variable
NLS_LANG=.ZHT16MSWIN950
(CP936 seems to be not supported by Oracle) or change your codepage before runningsqlplus.exe
with commandchcp 437
. With this proper settings you will not see any Chinese characters as you probably would have expected.