Mysql table name case-insensitive configuration methods

Source: Internet
Author: User

Mysql table name case-insensitive configuration methods

Mysql in linux is case sensitive by default. Whether mysql is case sensitive is determined by the lower_case_table_names parameter, where:

1) lower_case_table_names = 0

It is case sensitive (that is, it is not case sensitive). This setting is used by default. After this setting, the table name created in mysql does not contain uppercase letters, and can be read and referenced normally.

2) lower_case_table_names = 1

It is case insensitive (that is, it is case sensitive ). After this setting, the table name is saved in lower case on the hard disk, and MySQL converts all the table names to lower case storage and query tables.This behavior is also suitable for database names and table aliases..

That is to say, after mysql is set to be case-insensitive, the database or table is created regardless of whether uppercase letters are used during creation. After the creation is successful, it is forcibly saved in lower case!

In Linux, the database name, table name, column name, And alias are case-sensitive:

1) The database name and table name are case sensitive;

2) The table alias is case sensitive;

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

4) variable names are case sensitive;

5) MySQL is case-insensitive in Windows, but is case-sensitive by default in Linux.

6) If you want to query the case sensitivity of the time zone field value, you need to set the BINARY Attribute for the field value. There are multiple methods to set it:
A) set at creation:
Create table t (a varchar (10) BINARY );
B) Use alter to modify

Therefore, in order to make programs and databases run normally in different operating systems, the best way is to convert tables to lower case when designing them !!

Modify mysql to be case insensitive:

Mysqladmin-uroot-p shutdown // close the database in Safe Mode

Modify my. cnf // Add the following row
.....
[Mysqld]
Lower_case_table_names = 1
.....

Start mysql

The above explanation of the case-insensitive configuration method for mysql table names is all the content that I have shared with you. I hope you can give me a reference and support the help house.

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.