Sign up for Hasura Newsletter

Postgres Triggers

In this section, we will look at

  • What is a trigger and how it works
  • When to use triggers?
  • Examples of triggers

PostgreSQL Triggers are database callback functions, which are automatically performed/invoked when a specified database event occurs.

PostgreSQL trigger can be specified to fire on three different scenarios.

  • Before the operation is attempted on a row (before constraints are checked and the INSERT, UPDATE or DELETE is attempted)

  • After the operation has completed (after constraints are checked and the INSERT, UPDATE, or DELETE has completed)

  • Instead of the operation (in the case of inserts, updates or deletes on a view)

Did you find this page helpful?
Start with GraphQL on Hasura for Free
  • ArrowBuild apps and APIs 10x faster
  • ArrowBuilt-in authorization and caching
  • Arrow8x more performant than hand-rolled APIs
Promo
footer illustration
Brand logo
© 2021 Hasura Inc. All rights reserved
Github
Titter
Discord
Facebook
Instagram
Youtube
Linkedin