Home > Database > Mysql Tutorial > Is mysql query case sensitive?

Is mysql query case sensitive?

WBOY
Release: 2022-05-27 16:29:30
Original
15500 people have browsed it

The default query of mysql is not case-sensitive; if you need to be case-sensitive, you can use the Binary keyword to set the query statement to be case-sensitive when querying. The syntax is "select * from table name WHERE binary field = field value".

Is mysql query case sensitive?

The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.

Is mysql query case-sensitive

MySql default query is not case-sensitive. If you need to distinguish it, you must mark sensitive attributes in Binary when creating the table.

Examples are as follows:

 CREATE TABLE NAME(name VARCHAR(10));
Copy after login

For this table, by default, the results of the following two queries are the same:

SELECT * FROM TABLE NAME WHERE name='clip';
SELECT * FROM TABLE NAME WHERE name='Clip';
Copy after login

Add binary

select
*
from users
WHERE binary user_name = '张三'
AND status != 0
Copy after login

to the query statement Extended knowledge:

MySQL is not case-sensitive under Windows. After importing the script file into MySQL, the table name will be automatically converted to lowercase. As a result, you want to export the database to An error occurred when using it in a linux server.

Because the table name is case-sensitive under Linux, the table cannot be found. I checked a lot and said that I can change the settings of MySQL under Linux so that it is not case-sensitive. But is there a way to make it case-sensitive in Windows? It's case sensitive.

In fact, the method is the same, just change the MySQL settings in windows accordingly.

Specific operation:

Add a line in the MySQL configuration file my.ini:

lower_case_table_names = 0
Copy after login

Among them, 0: case-sensitive, 1: case-insensitive

MySQL's case rules for database names, table names, column names, and aliases under Linux are as follows:

1. Database names and table names are strictly case-sensitive;

2. Table aliases are strictly case-sensitive;

3. Column names and column aliases are case-insensitive in all cases;

4. Variable names are also strictly case-sensitive. Case-sensitive; MySQL is not case-sensitive under Windows

Recommended learning: mysql video tutorial

The above is the detailed content of Is mysql query case sensitive?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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