lower_case_table_names and table names are case problems

1 Introduction
In MySQL, the database corresponding to the data directory directory. Each database table corresponding to the at least one file in the directory database (possibly more, depending on the storage engine). Therefore, the use of case sensitivity Caozuoxitong determine the database name and table name case sensitivity.
In most Unix database and table names are case-sensitive, while Windows is not case sensitive. A notable exception is Mac OS X, Unix-based but uses its default file system type (HFS +), not case sensitive. However, Mac OS X also supports UFS volumes, which are case-sensitive, just as Unix.
Variable lower_case_file_system whether the data directory where the file system is case sensitive file names. ON Description capitalization for the file insensitive, OFF means sensitive.
For example, look under windows:

说明windows系统对大小写不敏感,mysql也默认设置为对大小写不敏感。

2 Case sensitivity rules
under linux:
database name and table name is strictly case-sensitive;
alias table is strictly case-sensitive;
the column names and column aliases in all cases are case insensitive;
the variable name It is strictly case-sensitive;
under windows:
are case-insensitive
under Mac OS (non-UFS volume):
not case sensitive

Parameter Description 3 (lower_case_table_names)
under unix lower_case_table_names default value Default value is the default value 0 .Windows 1 .Mac OS X is 2.

                        参数值                         解释

0 using the CREATE TABLE or CREATE DATABASE statement specifies uppercase and lowercase letters save the table name and the database name on the hard disk. Name is case sensitive. In the case-insensitive windows operating systems such as Mac OS x or the parameter is not always set to 0, if the force is set in a case-insensitive file system on --lowercase-table-names 0, and the use of different the case of access to MyISAM table name, index may cause damage.
1 table name in lowercase saved on the hard disk, the name comparison is not case sensitive. MySQL will convert all table names to lowercase on storage and lookup tables in. This behavior is also suitable for the alias name of the database and tables. This is the default for Windows.
2 table and database names using the CREATE TABLE or CREATE DATABASE statement on the hard disk to save the specified upper and lowercase letters, but MySQL converts them to lowercase on lookup table. Name comparison is not case sensitive, that is, according to the case to keep them, in accordance with lowercase to compare. Note: only available in the not case-sensitive file system innodb table names stored in lowercase!.
4 case-sensitive converted by the insensitive method
if the original database and the table is established case-sensitive, you want to convert are not case sensitive, you need the following 3 main steps:
1. Export database data via mysqldump .
2. Change in the my.cnf lower_case_tables_name = 1, and restart the mysql database.
3. The export data into mysql database.

5 precautions
to avoid problems caused by the case of a recommended naming convention is: the definition of databases, tables, columns, when used in all lowercase letters underlined the way, do not use any capital letters
can be used in any system lower_case_tables_name = 1. Using this option has the disadvantage that when using the SHOW TABLES or SHOW DATABASES, do not see the name turned out to be uppercase or lowercase.
Please note that if before the lower_case_tables_name before lower_case_tables_name = 0 to 1, before restarting mysqld, must first be converted to lowercase old database and table names in Unix.


原文地址:http://blog.csdn.net/jesseyoung/article/details/40617031
博客主页:http://blog.csdn.net/jesseyoung

Guess you like

Origin www.cnblogs.com/Dennis-mi/p/12036777.html