4 ms·
SQL is desperately in need of some updates. For starters, DELETE FROM should never be allowed without a WHERE clause. DBs should simply define that as malform
by earl 15y ago
SQL is desperately in need of some updates.
For starters, DELETE FROM should never be allowed without a WHERE clause. DBs should simply define that as malformed sql.
- ithkuil 15y agoor at least interactive sql shells could ask you if you are really sure
- mikeklaas 15y agoExactly. There is no need given TRUNCATE exists.
- user24 15y agowell, the only difference is that truncate also resets the auto-increment to zero. But you could allow where 1=1 to make it explicit if people really wanted an unbounded DELETE FROM.
- fmx 15y agoNo entirely. DELETE will work with cascading foreign keys, while TRUNCATE will not, at least on SQL Server. Also, DELETE is logged and (I believe) TRUNCATE is not. Having said that, I agree that a WHERE clause should be required - you can always say "WHERE 1=1" or similar if you really mean to delete all rows.