Case-sensitive MySQL database table names, column names, and aliases

Source: Internet
Author: User

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. Table aliases are case sensitive;

3. The column name and column alias are case-insensitive in all cases;

4. Variable names are case sensitive;

MySQL is case insensitive in windows.

Therefore, in different operating systemsProgramAnd the database can run normally, the best way is to convert them to lowercase at the design time, but if it has been standardized at the design time, in Windows, you only need to modify the database configuration as follows:

In the MySQL configuration file, my. ini [mysqld]
Add a row

Lower_case_table_names = 1

Parameter description:

0: Case Sensitive

1: case insensitive

In MySQL
The database and table pairs are located in the directories and files under those directories. Therefore, the sensitivity of the operating system determines the case sensitivity of the database and table names. This means that the database and table names are
Windows is case-insensitive, while in most types of UNIX
The system is case sensitive.

It is strange that the column name and column alias are case-insensitive in all cases, while the table alias is case-sensitive.

To avoid this problem, you 'd better define all the database naming rules in combination with lowercase letters and underscores instead of any uppercase letters.

Alternatively, you can force it to start with the-O lower_case_table_names = 1 parameter.
Mysqld (if -- defaults-file =... \ My. CNF is used
To read the specified configuration file and start mysqld.
You need to add a line under the [mysqld] section of the configuration file.
Lower_case_table_names = 1 ). In this way, MySQL
All table names will be automatically converted to lowercase characters during creation and search (this option defaults
1 in windows and 0 in UNIX. From MySQL 4.0.2
This option also applies to the database name ).

When you change this option, you must start mysqld
First, convert the old table name to lowercase letters.

In other words, if you want to retain the case-sensitive characters when creating a table in the database, set this parameter to 0:
Lower_case_table_names = 1
. Otherwise, you will find that the same sqldump script imports different results in different operating systems (all uppercase characters in windows are changed to lowercase letters ).

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.