Home > Database > Mysql Tutorial > body text

Detailed explanation of the method of ignoring case configuration of mysql table names

黄舟
Release: 2017-03-22 13:59:18
Original
1931 people have browsed it

The following editor will bring you a detailed explanation of the mysql table name ignoring case configuration method. The editor thinks it is quite good, so I will share it with you now and give it as a reference for everyone. Let’s follow the editor and take a look.

Mysql under Linux is case-sensitive by default in table names. Whether mysql is case-sensitive is determined by the parameter lower_case_table_names, where:

1) lower_case_table_names = 0

is case-sensitive (that is, for case-insensitive), this is the default setting. After this setting, it has no effect whether the table name created in mysql has capital letters or not, and can be read and quoted normally.

2) lower_case_table_names = 1

Not case sensitive (i.e. case sensitive). After this setting, table names are saved in lowercase on the hard disk, and MySQL converts all table names to lowercase for storage and lookup tables.

This behavior also applies to database names and table aliases.

In other words, after MySQL is set to be case-insensitive, when creating a library or table, regardless of the use of uppercase letters when creating it, after the creation is successful, it will be forced to be saved in lowercase!

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 Case is ignored in all cases;


4) Variable names are also strictly case-sensitive;


5) MySQL does not differentiate under Windows Upper and lower case, but the default under Linux is case sensitive.


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

a) Set it when creating:

CREATE TABLE T(A VARCHAR(10) BINARY);
b) Use alter to modify

So in order to make the program and database run normally in different operating systems, it is best to A good idea is to convert them all to lowercase when designing the table! !

Modify mysql to be case-insensitive:


##mysqladmin -uroot -p shutdown //With

Safe mode

Close the database
Modify my.cnf //Add the following line of settings

....
[mysqld]
lower_case_table_names=1
....
Start mysql

The above is the detailed content of Detailed explanation of the method of ignoring case configuration of mysql table names. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!