[{"data":1,"prerenderedAt":114},["ShallowReactive",2],{"term-t\u002Ftrigger":3,"related-t\u002Ftrigger":101},{"id":4,"title":5,"acronym":6,"body":7,"category":83,"description":84,"difficulty":85,"extension":86,"letter":87,"meta":88,"navigation":89,"path":90,"related":91,"seo":95,"sitemap":96,"stem":99,"subcategory":6,"__hash__":100},"terms\u002Fterms\u002Ft\u002Ftrigger.md","Trigger",null,{"type":8,"value":9,"toc":77},"minimark",[10,15,19,23,26,30,66,70,73],[11,12,14],"h2",{"id":13},"eli5-the-vibe-check","ELI5 — The Vibe Check",[16,17,18],"p",{},"A trigger is code that the database runs automatically when something happens — like automatically updating an 'updated_at' timestamp whenever a row changes. You do not call it manually; it fires by itself when the triggering event occurs.",[11,20,22],{"id":21},"real-talk","Real Talk",[16,24,25],{},"A trigger is a database object that automatically executes a specified function in response to a data event (INSERT, UPDATE, DELETE) on a table. Triggers can run BEFORE or AFTER the event, and for each row affected or once per statement. They are used for auditing, enforcing complex constraints, and automatic field updates.",[11,27,29],{"id":28},"show-me-the-code","Show Me The Code",[31,32,37],"pre",{"className":33,"code":34,"language":35,"meta":36,"style":36},"language-sql shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","-- Auto-update updated_at timestamp\nCREATE TRIGGER set_updated_at\nBEFORE UPDATE ON users\nFOR EACH ROW EXECUTE FUNCTION update_timestamp();\n","sql","",[38,39,40,48,54,60],"code",{"__ignoreMap":36},[41,42,45],"span",{"class":43,"line":44},"line",1,[41,46,47],{},"-- Auto-update updated_at timestamp\n",[41,49,51],{"class":43,"line":50},2,[41,52,53],{},"CREATE TRIGGER set_updated_at\n",[41,55,57],{"class":43,"line":56},3,[41,58,59],{},"BEFORE UPDATE ON users\n",[41,61,63],{"class":43,"line":62},4,[41,64,65],{},"FOR EACH ROW EXECUTE FUNCTION update_timestamp();\n",[11,67,69],{"id":68},"when-youll-hear-this","When You'll Hear This",[16,71,72],{},"\"The trigger automatically sets updated_at when a row is modified.\" \u002F \"Too many triggers make it hard to trace what's happening in the database.\"",[74,75,76],"style",{},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":36,"searchDepth":50,"depth":50,"links":78},[79,80,81,82],{"id":13,"depth":50,"text":14},{"id":21,"depth":50,"text":22},{"id":28,"depth":50,"text":29},{"id":68,"depth":50,"text":69},"database","A trigger is code that the database runs automatically when something happens — like automatically updating an 'updated_at' timestamp whenever a row change...","advanced","md","t",{},true,"\u002Fterms\u002Ft\u002Ftrigger",[92,93,94],"Function","Stored Procedure","Transaction",{"title":5,"description":84},{"changefreq":97,"priority":98},"weekly",0.7,"terms\u002Ft\u002Ftrigger","77Nm_piCCU4g7GM39FrrveGMoJQJUwx3zxn9Y0fbboc",[102,107,110],{"title":92,"path":103,"acronym":6,"category":104,"difficulty":105,"description":106},"\u002Fterms\u002Ff\u002Ffunction","general","beginner","A function is a reusable recipe. You write the steps once, give it a name, and call it whenever you need those steps done.",{"title":93,"path":108,"acronym":6,"category":83,"difficulty":85,"description":109},"\u002Fterms\u002Fs\u002Fstored-procedure","A stored procedure is a named program you write in SQL (and sometimes a procedural language) that lives inside the database.",{"title":94,"path":111,"acronym":6,"category":83,"difficulty":112,"description":113},"\u002Fterms\u002Ft\u002Ftransaction","intermediate","A transaction groups multiple database operations into one all-or-nothing bundle. Either ALL of them succeed, or NONE of them happen.",1776518319981]