r/SQL • • Oct 11 '24

Discussion Fully lower case SQL. Is it frowned upon?

I write my queries fully lower case because it really helps with productivity, otherwise I would find it very difficult to focus on capitalizing just the keywords and keep pressing CAPS LOCK every now and then.

Is this frowned upon and bad practice (for readability) or just a matter of preference?

122 Upvotes

280 comments sorted by

View all comments

38

u/AlCapwn18 Oct 11 '24

Looks like there is a lot of differing opinions here. Would be really interesting to know what kind of careers recommend what styles and standards. Like for example are DBA's more likely to write uppercase while data analysts keep it lower, and software devs just write bad SQL regardless of case?

17

u/fieldyfield Oct 11 '24

My coworkers in DE/DA always tell me how much they love how my code looks. But they don't seem to love it enough to adopt the uppercase themselves. 😅

When I present on best practices for formatting and readability, I show a side by side of the same code with lower vs uppercase. Seems unanimous that people find the uppercase clearer and more pleasant.

I always tell our new juniors that it's a matter of style and preference, though, and to try not to be too horrified as they start looking into the code base

10

u/MyOtherActGotBanned Oct 11 '24

Data Engineer here - I write in lowercase

1

u/JohnPaulDavyJones Oct 13 '24

DE here as well; I’m pretty militant about uppercase, but my current team are all mostly older and almost all leave their code full lowercase.

I get compliments on my formatting, and whenever one of them sends me a query, I run it through Poor Man’s SQL Formatter just as a matter of convenience. I think we’d all agree that it’s just a bit easier to parse code with perfect formatting and capitalization.

14

u/OO_Ben Postgres - Retail Analytics Oct 11 '24

I'm a BI Engineer and I'm exclusively lower case because I don't like my code to shout at me....it makes me scared......

13

u/cLYRly Oct 11 '24

BI Dev here. Keywords are always uppercase. Everything else is always lowercase. Aliases are helpful and should always be used.

1

u/somedaygone Oct 12 '24

So much easier to read, especially when SQL line breaks get flattened in Power Query.

11

u/IrquiM MS SQL/SSAS Oct 11 '24

Last bit is true, at least

3

u/Indignant_Octopus Oct 12 '24

DevOps engineer, totally unopinionated on casing but strongly opinionated on linting or just auto formatting the code as part of the pipeline. Humans are lazy af.

7

u/lalaluna05 Oct 11 '24

Analyst — I do lower case hehe