Home  >  Article  >  Database  >  How to set table name to be case-insensitive in mysql

How to set table name to be case-insensitive in mysql

WBOY
WBOYOriginal
2022-01-20 10:55:006083browse

Method: 1. Use root to log in and open the "/etc/my.cnf" file; 2. Add "lower_case_table_names=1" under the "mysqld" node in the file; 3. Use "service mysqld restart "Command to restart the mysql service.

How to set table name to be case-insensitive in mysql

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

How to set the table name in mysql to be case-insensitive

In Linux, mysql is case-sensitive, but in Windows, mysql is not case-sensitive. Upper and lower case.

So the following solutions are based on Linux system.

After logging in with the root account, add lower_case_table_names=1 after [mysqld] in /etc/my.cnf, restart the MYSQL service, and the setting is successful: the table names are case-insensitive;

lower_case_table_names parameter details:

lower_case_table_names = 0

Where 0: case sensitive, 1: case insensitive

MySQL database name under Linux, The case rules for table names, column names, and aliases 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;

MySQL is not case-sensitive under Windows.

3. If you want to distinguish the case of field values ​​when querying, then: the field value needs to set the BINARY attribute. There are many ways to set it:

A. Set when creating:

CREATE TABLE T(

A VARCHAR(10) BINARY);B. Use alter to modify

Recommended learning: mysql video tutorial

The above is the detailed content of How to set table name to be case-insensitive in mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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