Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
ocwjay5923y@Oktokolo SERIOUSLY? Every time I look anything up or read through my class reading, it's all very specifically uppercased for certain things. Thanks for the tip!
-
@ocwjay
Don't thank me! Thank @MrObvious as it is him who teached me the secrets of SQL (the third may frighten you)... -
C0D4681463y@ocwjay keywords aren't case sensitive, but if I ever see a query in a codebase where it's not uppercase for keywords..... so help me I'll change it.
-
@C0D4 What’s your stance on no sql DBs using caps for the collections? Seems like it’s not as much of a convention there (been using mongo for a few years now), but from all the years of using SQL I do tend to still use them for collection names at least.
-
C0D4681463y@EstrnAdventures I use snake_case but that's probably more to do with doing the same for tables in SQL for countless years.
Plus it makes the queries easier to read IMO.
SELECT
this_field,
this_other_field
FROM that_table
WHERE this_thing <= that_thing; -
@C0D4
Lets meet in the middle: Title case...
"Select count(*) as cunt From foobars F
Where someField is Not Null and anotherField in (1, 3, 5)" -
C0D4681463y@Oktokolo I see that a lot, it's so hard to read for large queries. Which is what I typically deal with (200+ lines) so formatting is a must for me.
-
@ocwjay The nice thing about SQL, which can pretty much fuck you up, is that there small nuances in how things are handled.
E.g.
sys.format_bytes calls the format_bytes function from the sys schema / database.
FORMAT_BYTES is an internal function, now in performance schema, but globally callable without schema prefix.
https://dev.mysql.com/doc/refman/...
The upper / lower casing is used through the docs.
One of the reasons I told many interns that I have a zero tolerance policy against unformatted SQL.
The "principle" above of calling a schema / database function vs. an internal function is pretty common, especially when you e.g. need to support many versions of MySQL and need polyfills or user defined functions.
The mistake of using internal function and query hitting the database with a lower version of MySQL where the function is not supported can be very fatal ;)
TLDR: Casing is important and if there's an style given in a documentation of the RDBMs, follow it closely. It might make your life much easier. -
ocwjay5923y@IntrusionCM thank you for the tips! I'll continue marrying my pinky finger to my caps lock key then haha
-
@C0D4
The titlecase was meant as a joke.
I guess it is like with the rule 34 - if i can think about a worse style, it probably is in use somewhere... -
C0D4681463y
-
bioDan61593yThere is actually a flag for being case sensitive in MySQL but its FALSE by default.
Thats the case in most DBs to my knowledge, but from MariaDB docs, it depends on OS. For Windows, it's not case-sensitive. For Linux, Database, table, table aliases and trigger names are affected by the systems case-sensitivity, while index, column, column aliases, stored routine and event names are never case sensitive.
Related Rants
Me: *newly learning MySQL*
Also me: time to buy wedding rings for my pinky finger and the caps lock key
joke/meme
mysql