我想你的NLS_SORT
参数是BINARY
. 在BINARY
排序中,字符串按照它们的二进制表达式排序,这意味着大写字母将排在小写字母之前:
SQL> alter session set nls_sort=binary;
Session altered
SQL> select model from client_source order by model;
MODEL
--------------------
1234
4g
Default
Unknown
default1
ipad
iphone
iphone simulator
ipod
ipod touch
test
NLS_SORT
您可以使用不同的值更改此行为。使用带后缀的值NLS_SORT
_CI
使其不区分大小写:
SQL> alter session set nls_sort=latin_ci;
Session altered
SQL> select model from client_source order by model;
MODEL
--------------------
Default
default1
ipad
iphone
iphone simulator
ipod
ipod touch
test
Unknown
1234
4g
您可以使用 移动前面的数字CASE
:
SQL> SELECT model
2 FROM client_source
3 ORDER BY CASE WHEN regexp_like(model, '^[[:digit:]]')
4 THEN 0
5 ELSE 1
6 END,
7 model;
MODEL
--------------------
1234
4g
Default
default1
ipad
iphone
iphone simulator
ipod
ipod touch
test
Unknown
此外,您可以使用该NLSSORT
函数来修改单个查询的排序首选项:
select model from client_source order by NLSSORT(model, 'NLS_SORT = LATIN_CI');