๐ŸŽ 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

Connection Pool
A cache of database connections that can be reused, avoiding the overhead of creating new connections for each request.
Time-Series Database
A database optimized for storing and querying timestamped data points like metrics, sensor readings, and event logs.
Row-Level Security (RLS)
A database feature that restricts which rows a user can access in a table based on security policies.
ORM (Object-Relational Mapping)
A technique that lets you interact with a database using object-oriented code instead of writing raw SQL queries.
Materialized View
A database object that stores the precomputed result of a query, offering faster reads at the cost of periodic refresh.
EXPLAIN Plan
A database command that shows how the query planner will execute a SQL query, revealing join methods, scan types, and estimated costs.
View All Databases Terms โ†’