Why SHOUT in your SQL?

Somewhere someone started the tradition of capitalizing keywords in SQL.   Its like shouting all the unimportant parts of the code and making what’s important harder to read.

   SELECT b.id as book_id, a.name as author, b.pub_date as publication_date FORM books b LEFT JOIN authors a on b.id = a.book_id WHERE foo_bar = 'Fibonacci';

I say stop doing that.  And use instead super indentation and formatting.  Pseudo English is easier to read when it is not capitalized.

   select
      b.id       as book_id,
      a.name     as author,
      b.pub_date as publication_date
   from
      books
      left join authors a on b.id = a.book_id
   where
      foo_bar = 'Fibonacci'

See: sql_prettyHelp

2 thoughts on “Why SHOUT in your SQL?”

  1. Capitalizing is a decent way to point out mysql keywords, which I do think is valuable. I see it as similar to how the ‘$’ sign in php and perl make it easy to scan code and see what’s going on. I can quickly look at your code and see, oh it’s a simple select and left join with a where clause.
    I do think that the beautify command should be standard on more db editors than navicat.

    1. Then it would follow we should capitalize keywords in other programming languages like python, php, and ruby. We don’t do that because that would look just awful. In those languages we use formatting to help see what’s going on. And that’s what I’m suggesting for SQL, as well. Thanks for your comments.

Leave a Reply to Thomas Cancel reply

Your email address will not be published. Required fields are marked *