Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are table names in MySQL case sensitive?

People also ask

Is MySQL case-insensitive?

The default collations used by SQL Server and MySQL do not distinguish between upper and lower case letters—they are case-insensitive by default. The logic of this query is perfectly reasonable but the execution plan is not: DB2.

Are table and column names case sensitive in SQL?

At the time of table creation, all columns are created with all lowercase names regardless of quoting. The column names in a select statement are not case sensitive even if quoted.

Is SQL name case sensitive?

No. MySQL is not case sensitive, and neither is the SQL standard. It's just common practice to write the commands upper-case. Now, if you are talking about table/column names, then yes they are, but not the commands themselves.

Should table names be capitalized?

1. Only Use Lowercase Letters, Numbers, and Underscores. Don't use dots, spaces, or dashes in database, schema, table, or column names. Dots are for identifying objects, usually in the database.


In general:

Database and table names are not case sensitive in Windows, and case sensitive in most varieties of Unix.

In MySQL, databases correspond to directories within the data directory. Each table within a database corresponds to at least one file within the database directory. Consequently, the case sensitivity of the underlying operating system plays a part in the case sensitivity of database and table names.

One can configure how tables names are stored on the disk using the system variable lower_case_table_names (in the my.cnf configuration file under [mysqld]).

Read the section: 10.2.2 Identifier Case Sensitivity for more information.


Database and table names are not case sensitive in Windows, and case sensitive in most varieties of Unix or Linux.

To resolve the issue, set the lower_case_table_names to 1

lower_case_table_names=1

This will make all your tables lowercase, no matter how you write them.


It depends upon lower_case_table_names system variable:

show variables where Variable_name='lower_case_table_names'

There are three possible values for this:

  • 0 - lettercase specified in the CREATE TABLE or CREATE DATABASE statement. Name comparisons are case sensitive.
  • 1 - Table names are stored in lowercase on disk and name comparisons are not case sensitive.
  • 2 - lettercase specified in the CREATE TABLE or CREATE DATABASE statement, but MySQL converts them to lowercase on lookup. Name comparisons are not case sensitive.

Documentation


Table names in MySQL are file system entries, so they are case insensitive if the underlying file system is.