Home > Database > Mysql Tutorial > body text

How Can I Achieve Case Sensitivity in MySQL Collations?

DDD
Release: 2024-11-26 09:14:09
Original
253 people have browsed it

How Can I Achieve Case Sensitivity in MySQL Collations?

Case Sensitivity in MySQL Collation

MySQL provides a wide range of collation types to handle data comparison and sorting. However, finding a collation that supports case sensitivity can be a bit challenging.

Is Case Sensitivity Supported?

The standard MySQL collations marked with "_ci" at the end inherently follow case-insensitive rules. However, according to the MySQL Manual, there are collations suffixed with "_cs" that offer case sensitivity.

Finding Case-Sensitive Collations

To view a list of "_cs" collations, execute the following query:

SHOW COLLATION WHERE COLLATION LIKE "%_cs"
Copy after login

Case Sensitivity with UTF-8

Although UTF-8 is commonly used, there are no "utf8_*_cs" collations available in MySQL. Instead, "utf8_bin" can be utilized for case-sensitive UTF-8 fields. Keep in mind that this may impact ordering (ORDER BY), which can be resolved using:

ORDER BY column COLLATE utf8_general_ci
Copy after login

These findings are sourced from MySQL forums and underscore the limited options for case-sensitive collations, particularly with UTF-8.

The above is the detailed content of How Can I Achieve Case Sensitivity in MySQL Collations?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template