Mysql database name and table name are case sensitive _ MySQL

Source: Internet
Author: User
In MySQL, databases and tables correspond to 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 case-insensitive in Windows, while in most Unix systems in MySQL, databases and tables correspond to 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 case-insensitive in Windows and are case-sensitive in most types of Unix systems. A special case is Mac OS X, which is used by the default HFS + file system. However, Mac OS x also supports UFS volumes, which are case sensitive in Mac OS X, just as they are on any Unix. See section 1.8.3 MySQL extension to ANSI SQL92.

Note: Although the database and table names in Windows are case-insensitive, you should not reference a given database or table in the same query. The following query will not work because it references a table with my_table and MY_TABLE:

Mysql> SELECT * FROM my_table WHERE MY_TABLE.col = 1;

Column names and column aliases are case-insensitive in all cases.

Table aliases are case sensitive. The following query will not work because it uses a and A to reference aliases:

Mysql> SELECT col_name FROM tbl_name AS a WHERE a. col_name = 1 or a. col_name = 2;

If it is difficult to use uppercase or lowercase letters in the memory database and table name, we recommend that you use the same conventions. for example, you can always use lowercase letters to create databases and tables.

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 small lines during storage and search. (This option also applies to database names starting from MySQL 4.0.2 .) Note: When you change this option, you must first convert the old table name to lowercase letters 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

In the [mysqld] section, add

Lower_case_table_names = 1

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.