Automate schema migrations using DizzleORM and GitHub Actions - Manage thousands of tenants with this workflow
PostgreSQL Tutorial/PostgreSQL Trigger Basics

PostgreSQL Triggers

A PostgreSQL trigger is a database object that automatically executes a function in response to an event such as insert, update, delete, or truncate. In this section, you will learn about triggers and how to use them effectively.

Section 1. Basic PostgreSQL Triggers

  • Introduction to PostgreSQL trigger – Give you a brief overview of PostgreSQL triggers, why you should use triggers, and when to use them.
  • Create trigger – Show you how to create your first trigger in PostgreSQL.
  • Drop trigger– Describe steps for using the DROP TRIGGER statement to delete a trigger from a table.
  • Alter trigger – Guide you on how to use the ALTER TRIGGER statement to rename a trigger.

Section 2. INSERT triggers

  • BEFORE INSERT triggers – Show you how to create a trigger that is activated automatically before an INSERT event occurs on the associated table.
  • AFTER INSERT triggers – Guide you on defining a trigger activated automatically after an INSERT event occurs on the associated table.

Section 3. UPDATE triggers

Section 4. DELETE triggers

Section 5. INSTEAD OF triggers

  • INSTEAD OF triggers – Show you how to use the INSTEAD OF trigger to customize the behavior of the INSERT, UPDATE, and DELETE operations on a view.

Section 6. TRUNCATE triggers

Section 7. Enabling & Disabling triggers

  • Disable trigger –  Show how to disable a trigger or all triggers that belong to a table.
  • Enable triggers – Learn how to enable a trigger or all triggers associated with a table.

Section 8. Listing triggers

  • Listing triggers –  List all triggers associated with a table or all triggers in the current database.

Section 9. Advanced triggers

  • Event trigger –  Introduce the event trigger that fires when an event related to a DDL statement occurs.
  • Conditional trigger – Define a conditional trigger that fires only when a condition is satisfied.

Last updated on

Was this page helpful?