MySQL case sensitivity and naming convention _ MySQL
Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
MySQL case sensitivity and naming rules bitsCN.com
MySQL case sensitivity and naming rules Note: For most of the content in this article, refer to relevant articles from the Internet 1. in MySQL, a database corresponds to a folder, and tables in the database are stored in the folder as files. therefore, the sensitivity of the operating system to the case sensitivity determines the case sensitivity of the database and table (MySQL has a read-only system variable lower_case_file_system, which reflects whether the current file system is case sensitive). therefore: in Windows, Mysql databases and table names are case-insensitive, while in most Unix systems, they are case-sensitive. The following are detailed MySQL case sensitivity rules: in Linux: 1. database names and table names are case-sensitive; 2. table aliases are case-sensitive; 3. the column name and column alias are case-insensitive in all cases. 4. variable names are case-sensitive. in Windows, all are case-insensitive. Supplement: 1. mySQL has a system variable: lower_case_table_names, which is used to configure whether to distinguish the case sensitivity between the database name and table name. If your system is Windows and you want mysql to be case sensitive, you can add the following parts at the end of the [mysqld] section in the my. ini file:
[Plain] # If set to 0, table names are stored as specified and comparisons are case sensitive. # If set to 1, table names are stored in lowercase on disk and comparisons are not case sensitive. # If set to 2, table names are stored as given but compared in lowercase. this option also applies to database names and table aliases. lower_case_table_names = 0 2. mySQL is case-insensitive when querying strings. If a field value is case sensitive, you can specify the BINARY attribute when defining this field. 2. A MySQL naming convention to avoid case sensitivity issues, a recommended naming rule is to use lowercase letters and underscores (_) to define databases, tables, and columns, do not use any uppercase letters. 3. automatic schema ING for Hibernate/JPA databases
The Hibernate/JPA project can automatically generate database schema. Because java has its own class and field naming rules, this is not consistent with the naming rules recommended by mysql, as a result, the question of which naming convention is follow. In general, this will be determined by the team and DBA through negotiation. the use of mysql naming conventions will not cause case-insensitive issues, and may be more friendly for DBAs, the use of java Naming rules is undoubtedly more user-friendly for developers, which will save the ing configuration of column names and facilitate developers to view the database. If your project uses the latter, set lower_case_table_names = 0.
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to firstname.lastname@example.org. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
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:
and provide relevant evidence. A staff member will contact you within 5 working days.