SQL – Reasons to Capitalize SQL Keywords

coding-standardshistorysql

There seem to be a lot of developers who write their SQL by capitalising the keywords:

SELECT column
FROM table
     INNER JOIN table
     ON condition
WHERE condition
GROUP BY clause
HAVING condition

I'm wondering why people stick to this approach? Clearly, it's a long established convention – but I've never run into a RDBMS that requires capitalisation.

Personally, I find KEYWORDS THAT SHOUT to be calling attention to exactly the wrong part of the query, which is why I write the keywords in lowercase.

Still, enough people use this convention that I figure I might be missing something, hence this question.

Best Answer

Capitalization makes them stand out, as opposed to the other characters that are in the query window.

The reason I don't do this as it's a huge time waster. You can do one of two things:

1) Hold your shift key down while typing out the word: way too error-prone and just haphazard.

2) Put on caps lock for the duration of the word: a bit too much of time consumption.

I use SQL Server, and the environment (SSMS) has great syntax highlighting so I don't personally believe keyword capitalization is as prevalent these days as it used to be (if at all).

It is good practice in books and online tutorials, though, so it is evident what the reserved keywords are. It's just one of those unwritten things.

Related Topic