DELETE Statement

SQL FundamentalsDMLFree Lesson

Advertisement

The DELETE Statement

The DELETE statement removes existing records from a table.

💡 DELETE removes rows from a table. Like UPDATE, always use a WHERE clause unless you want to delete everything!

Basic Syntax

DELETE FROM table_name WHERE condition;

Delete Specific Rows

DELETE FROM customers WHERE id = 5;
DELETE FROM customers WHERE city = 'New York';

Safe Delete Pattern

-- Step 1: Preview
SELECT * FROM customers WHERE city = 'Chicago';

-- Step 2: Delete
DELETE FROM customers WHERE city = 'Chicago';

-- Step 3: Verify
SELECT * FROM customers WHERE city = 'Chicago';

DELETE vs TRUNCATE vs DROP

OperationRemoves DataKeeps TableCan Use WHERESpeed
DELETEYesYesYesSlow
TRUNCATEYesYesNoFast
DROPYesNoNoFastest

⚠️ Deleted data is usually gone forever unless you're inside a transaction. Always backup before deleting.

✅ Key Takeaways

  1. DELETE removes rows from a table
  2. Always include a WHERE clause unless deleting all rows
  3. Preview with SELECT before deleting
  4. TRUNCATE is faster for deleting all rows
  5. Deleted data is permanent outside of transactions

Advertisement

Need Expert SQL Help?

Get personalized SQL training or database consulting.

Advertisement