A property that affects how you use identifiers is whether they're case sensitive; some identifiers are case sensitive and others are not. You should understand which is which and use them accordingly.
The rules that determine whether an identifier is case sensitive depend on what kind of identifier it is:
- For database and table identifiers, case sensitivity depends on the operating system and filesystem of the server host, and on the setting of the lower_case_table_names system variable. Databases and tables are represented by directories and files, so if the operating system has case-sensitive filenames, MySQL treats database and table identifiers as case sensitive. If filenames aren't case sensitive, these identifiers are not either. Windows systems do not have case-sensitive filenames, but most Unix systems do. However, if the lower_case_table_names system variable is set to 1 or 2, database and table identifiers and table aliases are used in case-insensitive fashion in SQL statements. If you plan to use this variable, you should set it before creating any databases and tables.
Regardless of the case-sensitive properties of your filesystem, database and table identifiers must be written consistently with the same lettercase throughout a given statement.
- Column, index, stored routine, and trigger identifiers are not case sensitive.
- Column aliases are not case sensitive.
Posted in: MySQL