Chinese phonetic sorting problem in Oracle database

Source: Internet
Author: User
Tags oracle database

Oracle database Chinese phonetic sorting problem, nls_sort setting

Before Oracle9i, Chinese is sorted according to binary encoding. In oracle9i, according to pinyin, radical, stroke sorting function.

1, set the Nls_sort parameter value

Schinese_radical_m sorted by radical (first order), stroke (second order)

Schinese_stroke_m sorted by stroke (first order), radical (second order)

Schinese_pinyin_m sorted by Pinyin

Binary_ci ignores case-insensitive sorting

2, the session level settings, modify the Oracle field default sorting method:

by Pinyin: Alter session set nls_sort = Schinese_pinyin_m;

By stroke: Alter session set nls_sort = Schinese_stroke_m;

By radicals: Alter session set nls_sort = Schinese_radical_m;

Ignore case: Alter session set Nls_sort = binary_ci;

3, the statement level set sorting method:

Sort by stroke

SELECT * FROM Dept ORDER by Nlssort (name, ' Nls_sort=schinese_stroke_m ');

Sort by radical

SELECT * FROM Dept ORDER by Nlssort (name, ' Nls_sort=schinese_radical_m ');

Sorted by Pinyin, this is the system's default sorting method

SELECT * FROM Dept ORDER by Nlssort (name, ' Nls_sort=schinese_pinyin_m ');

Ignore case

SELECT * FROM Dept ORDER by Nlssort (name, ' nls_sort=binary_ci');

4. Modify system parameters (Database operating system):

Set Nls_sort=schinese_radical_m export Nls_sort (SH)

Setenv nls_sort schinese_radical_m (CSH)

Hklc\software\oracle\home0\nls_sort (Win registration form)

5, set the query to ignore the case method:

Alter session set nls_sort= 'binary_ci';

Alter session set nls_comp= 'linguistic';

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.