r/SQL • u/badboyzpwns • May 20 '26
PostgreSQL What are common SQL red flags?
Hello! interview prepping, here wondering what are some common red flags for wrioting SQL?
Like
LIKE failing to index, not having trasnactions, usign SELECT * instead of specific collums, etc 😃
48
Upvotes
View all comments
Show parent comment
-6
u/foxsimile May 21 '26
It’s slightly more nuanced than this in certain cases, but not by much. This style of formatting is the one I’ve baked up over the years, and it’s dead simple and pretty handy (though arguably a bit much at times, but I’d far prefer too much to too little). Â
AS "Identifier"Perhaps I’m forgetting some things, habits being muscle memory and all that, but this covers it quite nicely. Â
Oh, and to echo what someone else has said (despite my example above, which was curtailed for brevity’s sake - ironic, I know), but the alias should always be a shorthand for the table. It should also be perfectly consistent across the statement (reference any use across the DB whatsoever). I take this a step further and also include the DB and Schema, both shorthanded. For example:
Also, as for the UPDATE:
WHERE (1=1)