In Oracle, how can I use SQL to check whether a field contains Chinese characters?

Source: Internet
Author: User


In Oracle, how can I use SQL to check whether the field contains Chinese Characters? Today, a colleague's data migration program has a problem. I didn't consider Chinese encoding characters. Because the migrated table has tens of millions of data, however, there are very few records in Chinese. can I find the number of records with Chinese content. First of all, I want to use the method of checking each byte ASCII. In this case, I need to write a UDF and call it in SQL to get the result. However, it seems that this method is time-consuming. After all, each character must be compared, so it is not implemented. Www.2cto.com suddenly came to mind that Oracle had a function for encoding conversion called Convert. If a character string contains non-ASCII characters before and after encoding conversion, the result is displayed. Finally, I wrote it and tested it. It is indeed feasible. The scan will end in 10 seconds after 55 million records are recorded. The following is a test case: SQL> select * 2 from (select 'abc' c1 from dual 3 union all 4 select 'AB test Cd' c1 from dual) 5 where c1 <> CONVERT (c1, 'us7ascii ', 'zhs16gbk'); C1 -------- test cd www.2cto.com CONVERT Function Description: CONVERT (inputstring, dest_charset, source_charset) inputstring: the string dest_charset to be converted: The target character set source_charset: the original character set. This is just a small trick. One day you may have such a requirement, which may be useful.
 

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.