ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 字符集测试

字符集测试

原创 Linux操作系统 作者:fengjin821 时间:2009-06-25 11:18:25 0 删除 编辑

这个数据库字符集是WE8ISO8859P1
------------------Beginning of TEST-----------------

EG:
On :
xxx-xxx$> setenv NLS_LANG AMERICAN_AMERICA.UTF8
SQL> create table testbyhao2 (name varchar2(100));

Table created.

SQL> insert into testbyhao2 values ('浩');

1 row created.

SQL> commit;

Commit complete.

SQL> select * from testbyhao2;

NAME
--------------------------------------------------------------------------------
?

SQL> select name,dump(name) from testbyhao2;

NAME
--------------------------------------------------------------------------------
DUMP(NAME)
--------------------------------------------------------------------------------
?

Typ=1 Len=1: 191



SQL> insert into testbyhao2 values ('朱');

1 row created.

SQL> commit;

Commit complete.

SQL> select name,dump(name) from testbyhao2;

NAME
--------------------------------------------------------------------------------
DUMP(NAME)
-------------------------------------------------------------------------------
?

Typ=1 Len=1: 191

?

Typ=1 Len=1: 191      


We can see that under NLS_LANG=AMERICAN_AMERICA.UTF8, when we insert 2 different Chinese words,
Actually in Oracle, they are both messy codes(“191”).
That is to say, we lost them!

And the workaround should be set the NLS_LANG to the same with database(AMERICAN_AMERICA.WE8ISO8859P1).

EG:

xxx-xxx$> env|grep -i nls

NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1
SQL> create table testbyhao(name varchar2(100)) tablespace cr_data;

Table created.

SQL> insert into testbyhao values('浩');

1 row created.

SQL> commit;

Commit complete.


SQL> select name,dump(name) from testbyhao;

NAME
--------------------------------------------------------------------------------
DUMP(NAME)
--------------------------------------------------------------------------------

浩

Typ=1 Len=3: 230,181,169

SQL> insert into testbyhao values('朱');

1 row created.

SQL>  commit;

Commit complete.


SQL>  select name,dump(name) from testbyhao;

NAME
--------------------------------------------------------------------------------
DUMP(NAME)
--------------------------------------------------------------------------------

浩

Typ=1 Len=3: 230,181,169


朱
Typ=1 Len=3: 230,156,177


We can see that when under the same character set with database,
The 2 Chinese words are displayed correctly and with 2 different codes.
------------------End of TEST-----------------

 

 


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/13165828/viewspace-607511/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: grant 的问题
下一篇: ORACLE字符集研究
请登录后发表评论 登录
全部评论

注册时间:2009-04-29

  • 博文量
    191
  • 访问量
    562866