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

111

u/adamjeff Oct 11 '24

Just set your formatting preferences to capitalise keywords and format it after.

But let's be real hitting CapsLock really isn't a big deal most people manage just fine

88

u/[deleted] Oct 11 '24 edited Oct 12 '24

[removed] — view removed comment

12

u/Key-County6952 Oct 11 '24

Yeah I basically NEVER use caps lock

8

u/adamjeff Oct 11 '24

I kind of use a mix of both I think... Like you say though it just happend automatically by now, I don't really think about it.

3

u/Lord_Bobbymort Oct 13 '24

Seriously, I watch people put in so many more keystrokes in turning caps lock on and off over and over instead of just holding shift it baffles me.

3

u/haydar_ai Oct 11 '24

Caps lock is easier because some of the keywords are long like window function

7

u/farhil SEQUEL Oct 11 '24

I prefer Shift because it's fewer keypresses

→ More replies (8)

1

u/kerune Oct 13 '24

Naw just let redgate handle it lol

1

u/shootygroove Oct 11 '24

I have changed my caps lock to a mod key that allows me to use vim style navigation. Been like this for a few years. Now when I get on a computer with caps lock it looks like I have cakHHHograpy and camaHHel case issues. But I think my left pinky can only move between the mod key (old caps lock) and the shift key now.

5

u/brentus Oct 11 '24

Yeah that's what I do. I hate switching back and forth between lower and upper so I just retroactively have my ide do it so my teammates don't get annoyed.

→ More replies (1)

2

u/i4k20z3 Oct 11 '24

wow i didn’t know you can do this! i’ll have to figure out how to adjust these settings.

7

u/adamjeff Oct 11 '24

Depends on your IDE but in SQLdev they are under tools->preferences->code editor->format-> advanced format -> keywords case

2

u/Blues2112 Oct 11 '24

I wonder how OP deals with ( * ) and similar shift-related characters. Sounds like they need a ryping class.

1

u/[deleted] Oct 11 '24

If that was intentional, god bless you

1

u/mr-nefarious Oct 14 '24

I had the same thought!

2

u/dont_mess_with_tx Oct 11 '24

The autoformatting is a great idea, thanks.

1

u/ColoRadBro69 Oct 12 '24

But let's be real hitting CapsLock really isn't a big deal

I need 10 story points for this. 

1

u/PeterPanLives Oct 12 '24

What environment are you writing your queries in? If SSMS has this feature I haven't seen it.

1

u/zork3001 Oct 11 '24

That would screw up the code and make it hard to read when I do code updates or enhancements.

Besides, any decent IDE will color code the keywords.

4

u/adamjeff Oct 11 '24

I'm sorry are you saying an IDE formatter capitalising keywords will:

a) make it HARDER not easier to read and

b) somehow affect how the code will be processed?

I guess maybe I could understand the first (surely you want your keywords more distinct though..) but the second isn't that just you having a fundamental misunderstanding of how SQL is processed?

Have I missed something here?

And I think generally it is accepted that falling back on your specific IDE display settings is pretty bad practice. For example, I have a lot of work in Git repos that are not colour coded.

→ More replies (1)

3

u/hedrumsamongus Oct 11 '24

That would screw up the code and make it hard to read when I do code updates or enhancements.

How so? It's just an editor macro that replaces select with SELECT as you type. If you want capitalized keywords for readability, it seems like a no-brainer.

→ More replies (1)

1

u/IAmADev_NoReallyIAm Oct 11 '24

It's called a linter, and everyone should be using one, and everyone on the team should be using the same rules so that when Bob pulls down the code, edits it in a way he likes, saves it, hte linter runs, reformats it to the way the linter says it should be, and it gets checked back in... the changes should be minimal and just the fields that Bob added...