特殊字符oracle

时间:2015-03-16 15:14:57

标签: sql oracle special-characters

看到我在Oracle数据库的表格中插入了一个特殊字符“μ”:

INSERT INTO ABBREV (ABBREV, DEFINITION) VALUES ('µg','microgram (one millionth of a gram, 10-6 gram)');
INSERT INTO ABBREV (ABBREV, DEFINITION) VALUES ('µmole','micromole');

当我选择我得到的数据时:

SQL> select * from ABBREV where DEFINITION like '%micro%';

ABBREV                         DEFINITION
------------------------------ --------------------------------------------------------------------------------
omi                            other micro-organisms
¿µg                            microgram (one millionth of a gram, 10 -6 gram)
¿µmole                         micromole

SQL> 

为什么我在“μ”之前得到“¿”以及如何在insert语句中避免它?

Oracle Database 11g Enterprise Edition Release 11.1.0.6.0
NLS_NCHAR_CHARACTERSET         AL16UTF16

1 个答案:

答案 0 :(得分:2)

要获得正确的解决方案,您必须根据本地代码页设置NLS_LANG环境变量。

看起来像这样:

C:\>chcp
Active code page: 850

C:\>set NLS_LANG=.WE8PC850

C:\>sqlplus ...

SQL> INSERT INTO ABBREV (ABBREV, DEFINITION) VALUES ('µmole','micromole');

1 row created.

SQL> 

另一种解决方案是使用函数UNISTR

INSERT INTO ABBREV (ABBREV, DEFINITION) VALUES (UNISTR('\00B5mole'),'micromole');