Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are MySQL queries almost always written in Capital

Tags:

mysql

I've seen most coders use Capital letters while writing MySQL queries, something like

 "SELECT * FROM `table` WHERE `id` = 1 ORDER BY `id` DESC"

I've tried writing the queries in small caps and it still works.

So is there any particular reason for not using small caps or is it just a matter of choice?

like image 631
ptamzz Avatar asked Feb 17 '12 09:02

ptamzz


3 Answers

It's just a matter of readability. Keeping keywords in upper case and table/column names lower case means it's easier to separate the two when scan reading the statement .: better readability.

Most SQL implementations are case-insensitive, so you could write your statement in late 90s LeEt CoDeR StYLe, if you felt so inclined, and it would still work.

like image 172
Rory McCrossan Avatar answered Sep 20 '22 15:09

Rory McCrossan


The case make no difference of the SQL engine. It is just a convention followed, just like coding conventions use in any of the programming languages

like image 38
Sunil Kumar B M Avatar answered Sep 21 '22 15:09

Sunil Kumar B M


You have to have a system - there are already a few questions on the site that deal with conventions and approaches. Try:

SQL formatting standards

like image 31
lap Avatar answered Sep 19 '22 15:09

lap