MySQL case sensitivity and naming convention _ MySQL
Source: Internet
Author: User
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.
BitsCN.com
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.