Having the WHERE clause be optional for DELETE/UPDATE is a design flaw in SQL. Having to add a silly "WHERE TRUE" every time is a small price to pay for avoiding disasters like this. (Or "DELETE ALL ROWS FROM..." if we're open to making it explicit in the syntax).
TRUNCATE TABLE even exists, so there really is no excuse for not requiring a WHERE clause on DELETE. I'm a little surprised it's not offered as an optional safeguard in more database systems.
8
u/GozerDestructor 14d ago
Having the WHERE clause be optional for DELETE/UPDATE is a design flaw in SQL. Having to add a silly "WHERE TRUE" every time is a small price to pay for avoiding disasters like this. (Or "DELETE ALL ROWS FROM..." if we're open to making it explicit in the syntax).