Explanation of oracle Specifying Sorting Method

  • 2021-07-01 08:27:38
  • OfStack

Before Oracle9i, Chinese was sorted by binary encoding. In oracle9i, the functions of sorting according to pinyin, radicals and strokes are added.
1. Set the NLS_SORT parameter value
SCHINESE_RADICAL_M sorted by radicals (first order) and strokes (second order) SCHINESE_STROKE_M sorted by strokes (first order) and radicals (second order) SCHINESE_PINYIN_M sorted by Pinyin

2. Session level setting, modify the default sorting mode of ORACLE field:
According to Pinyin: alter session set nls_sort = SCHINESE_PINYIN_M;
By stroke: alter session set nls_sort = SCHINESE_STROKE_M;
By radical: alter session set nls_sort = NLS_SORT=SCHINESE_RADICAL_M;

3. Set the sorting mode at the statement level:
Sort select * from dept order by nlssort by stroke (name, 'NLS_SORT=SCHINESE_STROKE_M');
Sort select * from dept order by nlssort by radical (name, 'NLS_SORT=SCHINESE_RADICAL_M');
Sort by Pinyin This is the default sorting method of the system
select * from dept order by nlssort(name,'NLS_SORT=SCHINESE_PINYIN_M');

4. Modify the system parameters (the operating system where the database is located):
set NLS_SORT=SCHINESE_RADICAL_M export NLS_SORT (sh) setenv NLS_SORT SCHINESE_RADICAL_M (csh) HKLC\ SOFTWARE\ ORACLE\ home0\ NLS_SORT (win Registry)


Related articles: