Case sensitivity problem for MySQL database name and table name

Source: Internet
Author: User
Tags lowercase table name mysql database

In MySQL, databases and tables correspond to directories and files in those directories. Thus, the sensitivity of the operating system determines the case sensitivity of database and table naming. This means that database and table names are case insensitive in Windows and are case-sensitive in most types of Unix systems. A special case is Mac OS X, when the default hfs+ file system is used. However, Mac OS X also supports UFS volumes, which are case-sensitive in Mac OS X as they are on any Unix. View Chapter 1.8.3 MySQL extensions to ANSI SQL92.

Note: Although database and table names are not case-sensitive in Windows, you should not use different capitalization in the same query to refer to a given database and table. The following query will not work because it references a table in my_table and my_table:

Mysql> SELECT * from my_table WHERE my_table.col=1;

The name of the column and the alias of the column are ignored in all cases.

The alias of the table is case-sensitive. The following query will not work because it refers to aliases with A and a:

Mysql> SELECT col_name from Tbl_name as a WHERE a.col_name = 1 OR a.col_name = 2;

If you have difficulty remembering the letter size of your database and table names, it is recommended that you use a consistent convention, such as always creating databases and tables in lowercase letters.

Another way to avoid this problem is to start mysqld with the-o lower_case_table_names=1 parameter. By default, this option is 1 in Windows and 0 in Unix.

If Lower_case_table_names is 1, MySQL converts all table names to lowercase when they are stored and found. (Starting with MySQL 4.0.2, this option also applies to database names.) Note that when you change this option, you must first convert the old table name to lowercase before starting mysqld.

$ pwd

/data1/etl/aiinsight/scheduleserver/mysql/support-files

$./mysql.server Stop

$ pwd

/data1/etl/aiinsight/scheduleserver/mysql/bin

./mysqld_safe--lower_case_table_names

Method 2: Modify the MY.CNF configuration file

Join under [mysqld]

Lower_case_table_names=1

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.