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

Replication
The process of copying and maintaining database data across multiple servers for redundancy, failover, and read scaling.
ACID
A set of four properties (Atomicity, Consistency, Isolation, Durability) that guarantee reliable database transactions.
Migration
A version-controlled change to a database schema that can be applied and reversed systematically.
Connection String
A formatted string containing all parameters needed to establish a connection to a database server.
MVCC (Multi-Version Concurrency Control)
A technique where the database maintains multiple versions of data to allow concurrent reads and writes without locking.
Database Backup
The process of creating copies of database data to protect against data loss from failures, corruption, or human error.
View All Databases Terms โ†’