AFTER DELETE triggers execute after rows are permanently removed from table.
OLD contains the deleted row values (read-only, NEW unavailable).
Perfect for final audit logging, summary recalculations, and cleanup operations.

Basic AFTER DELETE Syntax


OLD in AFTER DELETE
OLD = deleted row values (read-only).
NEW unavailable (row no longer exists).

Simple Deletion Audit



Summary Table Cleanup


Cache Cleanup


Notification on Deletion



Cross-Table Reference Cleanup


OLD Column Availability

AFTER DELETE

NEW

OLD

All columns

✓ (Read-only)

Complete Row Archiving



Revenue Summary Recalculation


Permissions Required


Testing AFTER DELETE Trigger

Execution Sequence

  1. DELETE statement executes
  2. Row permanently removed from table
  3. AFTER DELETE triggers fire (alphabetical order)
  4. Secondary operations complete

Performance Optimization



Common Use Cases

  • Comprehensive deletion audit trails
  • Aggregate/summary table maintenance
  • Cache cleanup operations
  • Orphaned reference removal
  • Compliance and regulatory logging
  • Notification workflows

Production Pattern: Complete Deletion Audit



Bulk DELETE Performance


Error Scenarios



Advanced Compliance Logging



Important Notes

  • OLD contains complete deleted row data
  • Cannot affect triggering table (already deleted)
  • Multiple AFTER DELETE triggers execute alphabetically
  • Transactional: secondary failures don't restore deleted rows
  • Perfect for "post-deletion" cleanup and logging

Execution Guarantees

Operation

Guaranteed

OLD access

Always

Audit logging

If no errors

Summary updates

If no constraint violations

Original DELETE

Always committed first

Key Points

  • AFTER DELETE fires post-permanent row removal
  • OLD provides complete deleted row data
  • Essential for audit trails and cleanup
  • Cannot restore deleted data from trigger
  • Executes per deleted row (linear scaling)
  • Secondary operations fully transactional