4 ms·
> TRUNCATE clearly states your intention to delete everything, but DELETE by default also deletes everything. btw. they are completly different. TRUNCATE basi
by merb 4y ago
> TRUNCATE clearly states your intention to delete everything, but DELETE by default also deletes everything.
btw. they are completly different.
TRUNCATE basically ignores all transaction semantices for the sake of performance (which can be really really bad) in mysql it can't be rolled back, in postgres it's not mvcc safe.
TRUNCATE most often uses either an exclusive lock or some other mechanism.
if you know what you are doing truncate can be helpful, but delete has its benefits as well and truncate should be avoided by beginners.
- andy81 4y agoThe other important factor is permissions. Truncate in MSSQL requires alter permissions, so a user that can wipe a table can also change its definition. Not true with delete.