beginnerSQL Fundamentals — DDL, DML & Constraints

What is the difference between TRUNCATE and DELETE?

DELETE: DML, logged row-by-row, can have WHERE clause, fires triggers, respects foreign keys, can be rolled back, slow for large tables. TRUNCATE: DDL, minimal logging (deallocates data pages), no WHERE clause, does NOT fire per-row triggers (fires statement-level), may not respect foreign keys (check DB), faster (O(1) vs O(n)). PostgreSQL: TRUNCATE CAN be rolled back (transactional DDL). MySQL: T

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to You need to add a NOT NULL column 'status' to a 500-million-row orders table in production. How do you do this without downtime?← Back to all SQL questions