Home > Database > Mysql Tutorial > Are mysql table names case sensitive?

Are mysql table names case sensitive?

WBOY
Release: 2022-01-18 16:29:53
Original
15061 people have browsed it

The table name of mysql is case-sensitive in Linux, but the table name of mysql in Windows is not case-sensitive; you can add a line "ower_case_table_names = parameters" in the MySQL configuration file "my.ini [mysqld]" to Set whether to be case sensitive.

Are mysql table names case sensitive?

The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.

Is the table name of mysql case-sensitive?

The case rules for MySQL database names, table names, column names, and aliases under Linux are Like this:

  • The database name and table name are strictly case-sensitive;

  • The alias of the table is strictly case-sensitive;

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

  • Variable names are also strictly case-sensitive;

MySQL is not case-sensitive under Windows.

So in order to make the program and database run normally in different operating systems, the best way is to convert them to lowercase during design. However, if the case has been normalized during design, then In the Windows environment, you only need to make changes to the database configuration.

The specific operations are as follows:

Add a line ower_case_table_names = 1# in the MySQL configuration file my.ini [mysqld]

##Parameter explanation:

0: Case-sensitive

1: Case-insensitive

In MySQL, databases and tables correspond to those directories directories and files.

Therefore, 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 on Windows but are case-sensitive on most types of Unix systems.

Column names and column aliases are case-insensitive in all cases, and table aliases are case-sensitive. To avoid this problem, it is best to use all lowercase letters plus underscores when defining database naming rules, without using any uppercase letters. Or you can force to start

mysqld with the -O lower_case_table_names=1 parameter (if you use the --defaults-file=...\my.cnf parameter to read the specified configuration file to start mysqld, you need to Add a line lower_case_table_names=1) under the [mysqld] section of the configuration file. In this way, MySQL will automatically convert all table names to lowercase characters during creation and lookup. This option defaults to 1 and is 0 in Unix.

Recommended learning:

mysql video tutorial

The above is the detailed content of Are mysql table names case sensitive?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template