龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 数据库类 > Oracle 技术 >

Oracle中的中文排序方式

时间:2011-03-14 23:24来源:未知 作者:admin 点击:
分享到:
测试中文排序的 数据库 版本: SQL select * from v$version; BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production PL/SQL Rel

测试中文排序的数据库版本:

  SQL> select * from v$version;

  BANNER

  --------------------------------------------------------------------------------

  Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production

  PL/SQL Release 11.1.0.6.0 - Production

  CORE    11.1.0.6.0      Production

  TNS for Linux: Version 11.1.0.6.0 - Production

  NLSRTL Version 11.1.0.6.0 - Production

  2. 创建测试表

  create table player (id number(16, 0), name varchar2(30));

  3. 检查字符集配置

  确认数据库字符集 american_america.AL32UTF8

  SQL>  select  name,value$  from  props$;

  NAME                           VALUE$

  ------------------------------ ------------------------------

  DICT.BASE                      2

  DEFAULT_TEMP_TABLESPACE        TEMP

  DEFAULT_PERMANENT_TABLESPACE   USERS

  DEFAULT_EDITION                ORA$BASE

  Flashback Timestamp TimeZone   GMT

  TDE_MASTER_KEY_ID

  DEFAULT_TBS_TYPE               SMALLFILE

  NLS_LANGUAGE                   AMERICAN

  NLS_TERRITORY                  AMERICA

  NLS_CURRENCY                   $

  NLS_ISO_CURRENCY               AMERICA

  NLS_NUMERIC_CHARACTERS         .,

  NLS_CHARACTERSET               AL32UTF8

  NLS_CALENDAR                   GREGORIAN

  NLS_DATE_FORMAT                DD-MON-RR

  NLS_DATE_LANGUAGE              AMERICAN

  NLS_SORT                       BINARY

  NLS_TIME_FORMAT                HH.MI.SSXFF AM

  NLS_TIMESTAMP_FORMAT           DDMON-RR HH.MI.SSXFF AM

 

  NLS_TIME_TZ_FORMAT             HH.MI.SSXFF AM TZR

  NLS_TIMESTAMP_TZ_FORMAT        DD-MON-RR HH.MI.SSXFF AM TZR

  NLS_DUAL_CURRENCY              $

  NLS_COMP                       BINARY

  NLS_LENGTH_SEMANTICS           BYTE

  NLS_NCHAR_CONV_EXCP            FALSE

  NLS_NCHAR_CHARACTERSET         AL16UTF16

  NLS_RDBMS_VERSION              11.1.0.6.0

  GLOBAL_DB_NAME                 ORA11G

  EXPORT_VIEWS_VERSION           8

  WORKLOAD_CAPTURE_MODE

  WORKLOAD_REPLAY_MODE

  DBTIMEZONE                     00:00

  32 rows selected.

  SQL>

  深入确认字符集

  SELECT DISTINCT (NLS_CHARSET_NAME(CHARSETID)) CHARACTERSET,

  DECODE(TYPE#, 1,

  DECODE(CHARSETFORM, 1, 'VARCHAR2', 2, 'NVARCHAR2', 'UNKOWN'),

  9,

  DECODE(CHARSETFORM, 1, 'VARCHAR', 2, 'NCHAR VARYING', 'UNKOWN'),

  96,

  DECODE(CHARSETFORM, 1, 'CHAR', 2, 'NCHAR', 'UNKOWN'),

  112,

  DECODE(CHARSETFORM, 1, 'CLOB', 2, 'NCLOB', 'UNKOWN')) TYPES_USED_IN

  FROM SYS.COL$

  WHERE CHARSETFORM IN (1, 2)

  AND TYPE# IN (1, 9, 96, 112);

  确认操作系统字符集设置

  [ora11g@bj55 ~]$ export NLS_LANG=american_america.al32utf8

  4. 填写测试数据

  。。。。

  SQL> insert into player values (17, '下午啦');

  1 row created.

  SQL> insert into player values (20, '八千米死亡线');

  SQL> set pagesize 60

  SQL>  select * from player;

  ID NAME
精彩图集

赞助商链接