๐ŸŽ New User? Get 20% off your first purchase with code NEWUSER20 ยท โšก Instant download ยท ๐Ÿ”’ Secure checkout Register Now โ†’
Menu

Categories

Databases Intermediate

What is Trigger?

A database object that automatically executes a specified function when certain events (INSERT, UPDATE, DELETE) occur on a table.

Triggers run automatically in response to data changes. They can execute BEFORE or AFTER the triggering event, and operate on each row or once per statement. Common uses include audit logging, data validation, maintaining derived data, and enforcing complex business rules.

In PostgreSQL, triggers call trigger functions written in PL/pgSQL. While powerful, overuse of triggers can make database behavior hard to debug and predict. Consider application-level logic for complex business rules.

Related Terms

Deadlock
A situation where two or more transactions permanently block each other by each holding locks that the other needs.
Soft Delete
A pattern where records are marked as deleted with a flag or timestamp rather than being physically removed from the database.
View
A virtual table defined by a SQL query that provides a simplified or restricted view of data from one or more tables.
Migration
A version-controlled change to a database schema that can be applied and reversed systematically.
Transaction
A sequence of database operations that are treated as a single unit โ€” either all succeed or all are rolled back.
Partitioning
A technique of dividing large database tables into smaller, more manageable segments while maintaining a single logical table.
View All Databases Terms โ†’