我的NLS
设置:
NLS_SORT POLISH
NLS_COMP BINARY
简单测试查询:
select * from (
select '11117' as x from dual
union
select '12988' as x from dual
union
select '14659' as x from dual
union
select '1532' as x from dual
union
select '18017' as x from dual
) order by x;
实际结果:
x
-----
11117
12988
14659
1532
18017
期望的结果:
x
-----
1532
11117
12988
14659
18017
问题:
有没有NLS
可以帮助我达到预期结果的设置?我知道我可以做order by to_number(x)
,甚至更好,order by lpad(x, 5)
但在这种情况下并不好 - 我需要一个不需要更改查询的系统范围的解决方案。
我尝试了什么:
order by nlssort(x, 'nls_sort=binary');
alter session set nls_sort='binary';