Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does capitalization matter in MySQL?

I can't find a reference about which part of a MySQL query is case sensitive.

Is there an overview of where capitalization matters?

Specifically, are any of these case sensitive:

  • database name
  • table name
  • column name

Is it tied to the OS? Configurable? Or some other combination of factors?

like image 913
Tyler DeWitt Avatar asked Dec 05 '12 23:12

Tyler DeWitt


People also ask

Is MySQL case sensitive or not?

Table names are stored in lowercase on disk and name comparisons are not case-sensitive. MySQL converts all table names to lowercase on storage and lookup.

Is MySQL primary key case sensitive?

yes. ci is case insensitive.

Is SQL case sensitive for names?

Case sensitivity rules in SQL statements vary for different statement elements, and also depend on what you are referring to and the operating system of the machine on which the server is running. SQL keywords and function names. Keywords and function names are not case sensitive. They can be given in any lettercase.


1 Answers

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 (and possibly more, depending on the storage engine). Consequently, the case sensitivity of the underlying operating system plays a part in the case sensitivity of database and table names. This means database and table names are not case sensitive in Windows, and case sensitive in most varieties of Unix.

.

The lower_case_table_names system variable also affects how the server handles identifier case sensitivity

You can read more about the topic here.

like image 51
Nick Rolando Avatar answered Sep 21 '22 06:09

Nick Rolando