Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are column and table name case sensitive in MySQL?

If I have a column names called category_id and Category_Id, are they different?

And if I have table called category and Category, are they different?

like image 392
shin Avatar asked Jan 05 '10 20:01

shin


People also ask

Is column name case sensitive in MySQL?

Column, index, stored routine, and event names are not case-sensitive on any platform, nor are column aliases. However, names of logfile groups are case-sensitive.

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 column name case sensitive in SQL?

The SQL Keywords are case-insensitive ( SELECT , FROM , WHERE , etc), but are often written in all caps. However in some setups table and column names are case-sensitive.

Should MySQL table names be capitalized?

SQL standard requires names stored in uppercase The SQL standard requires identifiers be stored in all-uppercase.


1 Answers

On Unix, table names are case sensitive. On Windows, they are not. Fun, isn't it? Kinda like their respective file systems. Do you think it's a coincidence?

In other words, if you are developing on Windows but planning on deploying to a Linux machine, better test your SQL against a Linux-based MySQL too, or be prepared for mysterious "table not found" errors at prod time. VMs are cheap these days.

Field (column) names are case-insensitive regardless.

EDIT: we're talking about the operating system on the MySQL server machine, not client.

like image 100
Seva Alekseyev Avatar answered Oct 14 '22 18:10

Seva Alekseyev