logo
Course

Creating a Table - Clauses

You've learned to use constraints to set a default timestamp. But what if we wanted an "updatedAt" field that reflected when the last change was? Do we need to do it in our code when we make updates to the row in the table? Not at all! There's a fourth part to our fields besides the name, type, and constraints. It's called a 'clause', and it's like a special instruction that we can attach to certain data types to define additional behavior or functionality. Clauses allow us to automate things in our database based on certain actions. For instance, if we add an "ON UPDATE" clause to a new field called 'updatedAt' in our table:

The rest of this lesson is waiting.
Join JS Mastery Pro to unlock it.

gsap
javascript
nextjs
react native
threejs

Get Full Access

$149 /month

Lock in a year & save—2 months free!

  • Access to all courses

  • Quizzes, mini-challenges, AI summaries, inline sandboxes

  • Participation in a private community

  • Build real production-grade apps

  • Mock interviews & project reviews

  • Weekly live sessions & member-only access