How does an Oracle SQL statement determine whether a field starts with a letter rather than a Chinese character?

Source: Internet
Author: User

Recently, I want to check the filling rules of a field in the table, and the results are very confusing. I want to use SQL statements to determine how a field starts with a letter rather than a Chinese character:

1. if lengthb (substr ("", 1,1) = 2 then

Chinese characters

Elseif lengthb (substr ("", 1, 1) = 1 then

Letter

End if

2. Use not like '\ %' to return records starting with a letter,

The returned result starts with a Chinese character using the like '\ %.

Principle: The asciistr () function converts non-ASCII code into binary code and adds \ before it. Therefore, if asciistr (acolumn) is a Chinese character, \

Example: select asciistr ('China') from dual;

China

Therefore, it is easy to distinguish Chinese characters from characters.

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.