SQLite query problem, caused by letter-case sensitivity

Source: Internet
Author: User
Tags sqlite sqlite database sqlite query

The current project is to use MySQL, this is the wrong choice, because it is not a server-client mode project, but a CS architecture project, MySQL This needs more complex configuration of the database is not appropriate. Need should be sqlite this kind of, embedded database.

So recently unified database replacement work, the previous MySQL database operation of all the interface into the SQLite database operation interface.

According to the logic of SQL statements are the same, as long as the use of the database C + + interface can be changed.

Then there is a problem that a table query is always wrong.

After debugging and experimentation, the user IDs in the query statements are all uppercase letters, and the actual database contains lowercase letters.

The query is empty because the string user_id ' f56dc7ad-2aab-499c-a1a5-0efc154e15e2 ' are all uppercase letters.

As a matter of fact:

USER_ID: f56dc7ad-2aab-499c-a1a5-0efc154e15e2, containing lowercase letters

Why wasn't there such a problem in MySQL before?

Because queries in MySQL are not sensitive to letter-case:

It can be seen that even if the letter F is inconsistent in size, it still succeeds in checking the

Finally, the way I solve this problem is to make the original case-sensitive sqlite become case insensitive, so it is consistent with the previous MySQL.

When you build a table:

CREATE TABLE if not exists User_cert (user_id char (+) not NULL COLLATE nocase,cert_id char (+) not null,id integer PR Imary key AutoIncrement);

The special table stipulates that COLLATE nocase will be able.

SQLite query problem, caused by letter-case sensitivity

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.