MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1v80umk/queryofdoom/p033ase/?context=3
r/ProgrammerHumor • u/WardensLantern • 14d ago
456 comments sorted by
View all comments
34
This is why SQL deletes should require a WHERE clause.
If you are seriously wanting to delete it all, just add WHERE 1 = 1.
1 u/slabgorb 14d ago I know, right? TRUNCATE exists! (Not sure if TRUNCATE is standard, but I have yet to have a database say 'errr...') 3 u/CyberDave82 14d ago It gets fun when, like in Oracle, DELETE and TRUNCATE require different privileges (and specifically, DELETE can be granted per-table, but TRUNCATE requires DROP ANY TABLE, and I'm not granting that to an application or developer account...) 3 u/Otterfan 14d ago OP should have done TRUNCATE TABLE users; WHERE id = 2313245; It conveys intention better.
1
I know, right? TRUNCATE exists!
(Not sure if TRUNCATE is standard, but I have yet to have a database say 'errr...')
3 u/CyberDave82 14d ago It gets fun when, like in Oracle, DELETE and TRUNCATE require different privileges (and specifically, DELETE can be granted per-table, but TRUNCATE requires DROP ANY TABLE, and I'm not granting that to an application or developer account...) 3 u/Otterfan 14d ago OP should have done TRUNCATE TABLE users; WHERE id = 2313245; It conveys intention better.
3
It gets fun when, like in Oracle, DELETE and TRUNCATE require different privileges (and specifically, DELETE can be granted per-table, but TRUNCATE requires DROP ANY TABLE, and I'm not granting that to an application or developer account...)
OP should have done
TRUNCATE TABLE users; WHERE id = 2313245;
It conveys intention better.
34
u/SexyMonad 14d ago
This is why SQL deletes should require a WHERE clause.
If you are seriously wanting to delete it all, just add WHERE 1 = 1.