r/SQL • • 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 😃

51 Upvotes

192 comments sorted by

View all comments

Show parent comment

1

u/throw_mob May 21 '26

some things i agree

comma should start line

select ...

, x as y

from ...

fully qualified names and case sensitive object names i dont. i camelCase is for other usages sql should be full of snake_case

but fully qualified names depends systems you use.

something like this

select .. from customer_prod.base_information cust

works if your test systems are in own database, in little different systems schema is what changes so i prefer playing with active database and schema session variables, i do not like systems that change once written and tested code just to handle dev/prod environments, session is for that.

case sensitivity is just NO , once you have used time to figure out that id , Id and ID is same table and you have to point them using "ID" and "Id" ... it just is not clear way to present data.

aliases with "as" is something that i used to do , it is only required n cte definitions , so i have started to loose those in context of one query. it is still good idea to have one query looking about same

update/deletes should have always IDE checking that there is where clause , no 1=1 as default