Skip to main content

What is a trigger in MySQL?

Mid MySQL
Quick Answer Triggers automatically execute SQL code BEFORE or AFTER INSERT, UPDATE, or DELETE on a table. Use cases: audit logging (record who changed what), maintaining denormalized data, enforcing complex business rules. Each table can have 6 trigger types (BEFORE/AFTER x 3 operations). Triggers can slow write performance - use sparingly. Access OLD (pre-change) and NEW (post-change) row values.

Answer

A trigger executes automatically before or after INSERT, UPDATE, or DELETE, useful for logs or business rules.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice