3 ms·
A third variant: SELECT * FROM my table has a purpose, which is to visually separate SQL statements from table and column names.
by nicoburns 10y ago
A third variant:
SELECT * FROM my table
has a purpose, which is to visually separate SQL statements from table and column names.
- lostboys67 10y agoWhich is how you should write SQL in my opinion (and many others) it makes it much clearer and easier to understand. The other advantage it makes bugs where you use a Reserved word where you should not much easier to see visually
- vog 10y agoIndeed, this is a common workaround when your editor has no proper syntax highlighting. Still, in today's world nobody would write in that style in other programming languages. You see the same issue with other relicts, for example, Pascal back in the 90s. Old text books wrote Pascal in uppercase style: PROGRAM HelloWorld(output); BEGIN ... END. But in reality, everybody using e.g. the Turbo Pascal IDE wrote lowercase instead, because it easier to type and because of proper syntax highlighting: program HelloWorld(output); begin ... end. Maybe this is not so much about the maturity of the developers (as I assumed in the previous comment), but about the maturity of the tooling.
- lostboys67 10y agoyou do know that some SQL's are case sensitive for table names etc ?
- smoothdeveloper 10y agoHence I found it easier to keep all lowercase to avoid headaches.
- mbrock 10y agoThere's also a good argument for not relying on "proper" syntax highlighting which is not always available -- especially not for such a divergent language family as SQL. Every RDBMS has its own set of keywords and reserved words, so it's pretty much impossible to maintain a "proper" syntax highlighting mode.
- cr0sh 10y agoPretty much this - hence my upvote for you. I also like to stylistically indent my SQL to make it easier to follow. This works well for most typically use cases, but it can fail horribly when you start to certain kinds of JOINs and such - the indenting will make things more difficult to read. Of course, once you start doing really wild things with SQL, no amount of casing or indentation will save you.
- flukus 10y agoHad a purpose. Now we have syntax highlighting.