MySQL query is case sensitive.

Source: Internet
Author: User

Usually, data storage needs to specify the case sensitivity of string fields. MySQL Default queries are not case sensitive. However, as user information, once the user name is repeated, it will waste a lot of resources. In addition, it is difficult to identify the problems caused by the increase of Li Xiao and Li GUI. To do this, either when creating a table, it is case-sensitive (the field is case-sensitive ). If all fields in the overall database need to be case sensitive, it is better to adjust the character set settings. However, this is generally not recommended.

If, like me, the database has been running online and a table contains millions of data records, changing the field type may cause the database to go down. Well, it's better to add more words during the query!
For example, general query:

SELECT * FROM 'user' WHERE name LIKE 'a % ';
The results are the same. to distinguish between 'a % 'and 'a %', you can do this:
SELECT * FROM 'user' WHERE binary name LIKE 'a % ';
You can get different results if you only have one binary file!

Of course, you can write this statement if you need to make the table case sensitive:
Create table 'user' (name varchar (20) binary );

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.