AFTER UPDATE triggers execute after row modifications successfully persist.
Access both OLD (previous values) and NEW (updated values) for change detection.
Ideal for audit logging, recalculating aggregates, cache invalidation, and notifications.

Basic AFTER UPDATE Syntax


OLD/NEW in AFTER UPDATE
OLD = previous row values (before UPDATE).
NEW = current row values (after UPDATE).
Both read-only after UPDATE completes.

Change Detection Audit



Comprehensive Change Logging


Summary Table Recalculation



Cache Invalidation


Notification on Status Change



Cross-Table Updates



OLD/NEW Availability

AFTER UPDATE

NEW

OLD

All columns

✓ (Read-only)

✓ (Read-only)

Revenue Recalculation


Inventory Adjustment


Permissions Required


Testing AFTER UPDATE Trigger


Execution Sequence

  1. UPDATE identifies affected rows
  2. BEFORE UPDATE triggers execute
  3. Row changes persist to table
  4. AFTER UPDATE triggers execute (alphabetical order)

Performance Optimization


Common Use Cases

  • Detailed audit trails with OLD/NEW comparison
  • Aggregate/summary table maintenance
  • Cache invalidation
  • Cross-referencing table synchronization
  • Business process notifications
  • Compliance logging

Production Pattern: Complete Order Audit



Bulk UPDATE Performance



Error Handling

  • Trigger failures roll back entire UPDATE
  • Secondary table constraints respected
  • Transactional consistency maintained

Important Notes

  • Both OLD and NEW read-only after UPDATE
  • Cannot modify triggering table
  • Alphabetical execution order for multiple triggers
  • WHERE clause optimizes conditional logging
  • Perfect for "after the fact" processing

Advanced Conditional Logic



Key Points

  • AFTER UPDATE fires post-successful modification
  • OLD/NEW comparison enables change detection
  • Perfect for audit trails and recalculations
  • Can update other tables, not triggering table
  • Transactional: failures roll back everything
  • Use WHERE clauses for performance