web dev//SQL//trigger
A trigger is code that runs automatically when something happens in a table: the application never calls it, the database does. When Roberto's apartment is sold, for instance, a trigger automatically invalidates all his matches, with zero extra code in the backend.
A trigger is code that runs automatically when something happens in a table: the application never calls it, the database does. When Roberto's apartment is sold, for instance, a trigger automatically invalidates all his matches, with zero extra code in the backend.
It fires on INSERT, UPDATE or DELETE, and it can run BEFORE or AFTER the event.
A trigger is a function (CREATE FUNCTION) + a binding (CREATE TRIGGER ... ON table). The function defines the logic, the binding defines when it fires.
In Supabase, triggers are created in the SQL Editor. The Table Editor can't touch them: it only shows rows.
Triggers are the invisible automation layer, one of the things that make a database more than a spreadsheet. The data reacts to itself, and with RLS, which filters reads as triggers automate writes, the database governs itself without application code.