1719
top 50 comments
sorted by: hot top controversial new old
[-] xmunk@sh.itjust.works 176 points 8 months ago

Speaking as a Senior Dev specialized in database access and design... you don't have to use all caps - SQL is actually case agnostic.

But... but my fucking eyes man. I'm old, if your branch doesn't have control keywords in all caps I'm going to take it out back and ol' yeller it.

There are few hills I'll die on but all caps SQL and singular table names are two of them.

[-] Nolegjoe@lemmy.world 71 points 8 months ago

I'm a sql developer, and I am completely the opposite to you. I will find it incredibly difficult to read when everything is in caps

[-] Pechente@feddit.de 131 points 8 months ago

You should do a project together

[-] agressivelyPassive@feddit.de 42 points 8 months ago
[-] DmMacniel@feddit.de 30 points 8 months ago

The commit wars will be long and bloody.

[-] SorteKanin@feddit.dk 25 points 8 months ago

Same, I prefer lower case. Every other language has keywords in lower case, why do you need to shout when writing sql?

[-] hikaru755@feddit.de 21 points 8 months ago* (last edited 8 months ago)

I understand it as an attempt to get very basic, manual syntax highlighting. If all you have is white text on black background, then I do see the value of making keywords easy to spot by putting them in all caps. And this probably made sense back when SQL was first developed, but it's 2023, any dev / data scientist not using a tool that gives you syntax highlighting seriously needs to get with the times

[-] xmunk@sh.itjust.works 12 points 8 months ago* (last edited 8 months ago)

Partially, yes. I personally use an IDE with excellent syntax highlighting and those have been around for at least two decades. You are, however, often transplanting your SQL between a variety of environments and in some of those syntax highlighting is unavailable (for me at least) - the all caps does help in those rare situations.

More importantly though it helps clearly differentiate between those control keywords (which are universal) and data labels (which are specific to your business domain). If I'm consulting on a complex system that I only partially understand it's extremely helpful to be able to quickly identify data labels that I'm unfamiliar with to research.

load more comments (15 replies)
[-] Simulation6@sopuli.xyz 13 points 8 months ago

Just some key words in uppercase (FROM, JOIN,WHERE,etc) so they pop out

load more comments (1 replies)
[-] neo@lemmy.comfysnug.space 10 points 8 months ago

THE DATABASE CAN'T HEAR ME IF I DON'T SCREAM

load more comments (1 replies)
[-] xmunk@sh.itjust.works 18 points 8 months ago* (last edited 8 months ago)

Sorry, to clarify, not everything is in all caps. I'll append my prefered syntax below

WITH foo AS (
    SELECT id, baz.binid
    FROM
            bar
        JOIN baz
            ON bar.id = baz.barid
)
SELECT bin.name, bin.id AS binid
FROM
        foo
    JOIN bin
        foo.binid = bin.id

The above is some dirt simple SQL, when you get into report construction things get very complicated and it pays off to make sure the simple stuff is expressive.

[-] NedDasty@lemmy.world 14 points 8 months ago

You indent your JOIN? Why on earth? It lives in the same context as the SELECT.

load more comments (3 replies)
load more comments (3 replies)
load more comments (2 replies)
[-] erogenouswarzone@lemmy.ml 18 points 8 months ago

The place I work decided to name all tables in all caps. So now every day I have to decide if I want to be consistent or I want to have an easy life.

[-] xmunk@sh.itjust.works 11 points 8 months ago

Fuuuuck. That's why I love postgres... and fuck anyone that requires double quoted identifiers for special casing.

load more comments (3 replies)
load more comments (1 replies)
load more comments (10 replies)
[-] umbraroze@kbin.social 157 points 8 months ago

Technically, SQL is case-insensitive.

Practically, you want to capitalise the commands anyway.

It gives your code some gravitas. Always remember that when you're writing SQL statements you're speaking Ancient Words of Power.

Does that JavaScript framework that got invented 2 weeks ago by some snot-nosed kid need Words of Power? No. Does the database that has been chugging on for decades upon decades need Words of Power? Yes. Words of Power and all the due respect.

[-] hakunawazo@lemmy.world 17 points 8 months ago

Reminds me a bit of Skyrim. You are... the query-born.

[-] manny_stillwagon@mander.xyz 9 points 8 months ago

I'm going to print this out and frame it on the wall of my office.

load more comments (5 replies)
[-] bappity@lemmy.world 72 points 8 months ago

UM ACKSHULLY SQL ISN'T CASE SENSITIVE ☝️🤓

[-] Queuewho@lemmy.world 16 points 8 months ago

Please tell that to the git overlords at my work. They won't approve a merge with even a single unnecessary capitalization.

load more comments (4 replies)
[-] rwhitisissle@lemmy.ml 48 points 8 months ago* (last edited 8 months ago)

The phrase "SQL programmers" is so fucking weird. SQL isn't a programming language. It's a query language. You don't "program" things with SQL. You utilize SQL as a component of programs for data insertion and lookup, but the actual logic of execution is done in a programming language. Unless you're doing Oracle PL/SQL, in which case why are you giving money to Oracle?

Edit: Damn, this comment made people mad.

[-] oce@jlai.lu 42 points 8 months ago

Your knowledge of data engineering may be limited. SQL is predominant in data processing nowadays. FOSS tools such as DBT allows to write efficient data processing pipelines with SQL and some YAML config without the need for a general purpose coding language.
Why would anyone want that? Because SQL has the interesting property of describing the result you want rather than describing how to compute it. So you can put inside the database, a query engine with decades of optimizations, that will make a much better job at finding the best execution plan than the average developer.
It also means it's easier to train people for data processing nowadays.

load more comments (1 replies)
[-] KarmaPolice@lemmy.world 38 points 8 months ago

Most database engines support stored procedures. You don't need to give money to oracle, you can give it to Microsoft instead.

[-] fmstrat@lemmy.nowsci.com 18 points 8 months ago* (last edited 8 months ago)

Or not at all? Postgres? MariaDB? I think I missed the /s. I'm slow hah

load more comments (1 replies)
[-] SomeNewThing@reddthat.com 34 points 8 months ago* (last edited 8 months ago)

T-SQL is turing complete. While the MS SQL server has limitations on OS level operations, if you allow yourself some leeway with CLR wrappers for the win32 API, there's no reason I can think of you wouldn't be able to get the database engine to be a webserver reacting to incoming requests on port 80, or drawing GUIs based off of table state.

It's be slow and terrible, but doable.

load more comments (1 replies)
[-] fmstrat@lemmy.nowsci.com 31 points 8 months ago

This doesn't make sense to me. SPs and functions are in every major database. If I wrote a bash script that runs like a program, and sounds like a program, did I program it? Script it?

And lots of systems have nested logic in the DB, optimization often leads to that to reduce overhead. Unless you're being lazy with an ORM like prisma that can't even join properly.

Getting high performing queries is just as difficult as any other programming language, and should be treated as such. Even Lemmy's huge performance increases to .18ish came from big PG optimizations.

[-] mbp 11 points 8 months ago

It seems to be about yelling at others that "you're not a real programmer!!!" mixed with being so "technically correct" my eyes can no longer roll the same way they used to.

load more comments (3 replies)
[-] Gentoo1337@sh.itjust.works 30 points 8 months ago

I'm a markdown programmer and i disagree with this statement

load more comments (1 replies)
[-] dan@upvote.au 23 points 8 months ago* (last edited 8 months ago)

You don't "program" things with SQL

Why not? It sounds like you haven't written any OLAP queries :)

I've written ETL data pipelines using a system similar to Apache Airflow, where most of the logic is in SQL (either Presto or Apache Spark) with small pieces of Python to glue things together. Queries that are thousands of lines long that take ~30 minutes to run and do all sorts of transformations to the data. They run once per day, overnight. I'd definitely call that programming.

Most database systems support stored procedures, which are just like functions - you give them some input and they give you some output and/or perform some side effects.

load more comments (2 replies)
[-] corship@feddit.de 23 points 8 months ago* (last edited 8 months ago)
load more comments (6 replies)
[-] Cold_Brew_Enema@lemmy.world 41 points 8 months ago

As a senior query writer, I use caps for begin and end and some other commands, but all caps makes my head hurt. It's like the sql is screaming at me. I think it's more important to have good looking queries with proper indentation.

load more comments (2 replies)
[-] AlexWIWA@lemmy.ml 23 points 8 months ago

Writing SQL on Mac sucks so bad. I hate their caps lock time out

[-] icedterminal@lemmy.world 23 points 8 months ago

macOS has a caps lock timeout? The fuck...

[-] st0v@lemmy.zip 19 points 8 months ago

capslock drains the battery too quickly

load more comments (5 replies)
[-] AlexWIWA@lemmy.ml 10 points 8 months ago

Timeout was the wrong word. It has to be held for like a quarter second or something like that. It's annoying as hell.

load more comments (11 replies)
[-] VantaBrandon@lemmy.world 21 points 8 months ago

I know a Perl programmer who exclusively writes all SQL in pure lowercase with atypical indentation.

He's also a die-hard InfoWars follower, apparently his go to source, so... maybe there is a connection there.

load more comments (1 replies)
[-] HiddenLayer5@lemmy.ml 21 points 8 months ago* (last edited 8 months ago)

MySQL gives you a half-hearted "Bye" when you exit the console.

[-] dan@upvote.au 17 points 8 months ago

My favourite MySQL error is "MySQL server has gone away", like MySQL decides "nah I don't want to run this" and runs off.

(it happens when no data is sent over the connection for a while, like if the query is taking too long to run and times out)

load more comments (1 replies)
[-] Random_user@lemmy.world 15 points 8 months ago

Wait, you guys aren't just writing code and then hitting the FORMAT button?

load more comments (1 replies)
[-] uis@lemmy.world 13 points 8 months ago
load more comments (1 replies)
[-] MargotRobbie@lemm.ee 12 points 8 months ago

THANKS, NOW I DON'T HAVE TO HOLD DOWN THE SHIFT KEY WHEN I TYPE ANYMORE!

[-] revlayle@lemm.ee 11 points 8 months ago

I never use all caps when I write SQL, not sure why people insist on it so much

load more comments (6 replies)
[-] Album@lemmy.ca 11 points 8 months ago

If you guys think that's cool you should see what I can do with a double negative.

load more comments (6 replies)
[-] tentaclius@lemm.ee 10 points 8 months ago

Nobody knows (/s) but you don't have to write keywords in upper case (for most DB's default settings anyway).

[-] dylanTheDeveloper@lemmy.world 11 points 8 months ago

You can even write them sarcastically like this:

sElEcT * fRoM dUaL

load more comments (2 replies)
load more comments
view more: next ›
this post was submitted on 19 Oct 2023
1719 points (98.8% liked)

Programmer Humor

31314 readers
26 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 4 years ago
MODERATORS