Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Should mysql table names be case-sensitive?

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

The main content of this article is to explain "should mysql table names be case-sensitive?" interested friends might as well take a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "should mysql table names be case-sensitive?"

Mysql is case-sensitive in linux, and mysql is case-insensitive in Windows; you can add a line of "ower_case_table_names = parameter" to MySQL's configuration file "my.ini [mysqld]" to set whether it is case-sensitive.

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

Are mysql table names case sensitive?

The MySQL database name, table name, column name and alias case rules under Linux are as follows:

Database names and table names are strictly case-sensitive

Aliases for tables are strictly case sensitive

Column names and column aliases are case ignored in all cases

Variable names are also strictly case-sensitive

MySQL is not case-sensitive under Windows.

Therefore, in order to make the program and database run normally in different operating systems, the best way is to convert them to lowercase at the time of design, but if the case has been standardized at the time of design, all you have to do is to make changes to the configuration of the database in the Windows environment.

The specific operations are as follows:

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

Parameter explanation:

0: case sensitive

1: case-insensitive

In MySQL, database and table pairs are located in directories and files under those directories.

Therefore, the sensitivity of the operating system determines the case sensitivity of database and table names. This means that databases and table names are case-insensitive in Windows and case-sensitive in most types of Unix systems.

Column names and column aliases are case-sensitive in all cases, while table aliases are case-sensitive. To avoid this problem, you'd better use all lowercase letters plus underscores when defining database naming rules, instead of using any uppercase letters. Or you can force startup with the-O lower_case_table_names=1 parameter

Mysqld (if you use the-- defaults-file=...\ my.cnf parameter to read the specified configuration file to start mysqld, you need to add a line of 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 0 in Unix.

At this point, I believe you have a deeper understanding of "should mysql table names be case-sensitive?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report