Recall & Review
beginner
What does the
NEW keyword represent in a PostgreSQL trigger?NEW holds the new row data for INSERT or UPDATE operations inside a trigger function.
Click to reveal answer
beginner
What does the
OLD keyword represent in a PostgreSQL trigger?OLD holds the old row data for UPDATE or DELETE operations inside a trigger function.
Click to reveal answer
beginner
Can you use
NEW in a DELETE trigger?No. NEW is not available in DELETE triggers because no new row is created.
Click to reveal answer
beginner
In which trigger events is
OLD available?OLD is available in UPDATE and DELETE triggers because the old row exists before the change.
Click to reveal answer
beginner
How do you access the
NEW record's column named price inside a trigger function?Use NEW.price to get the value of the price column in the new row.
Click to reveal answer
Which keyword gives you the old row data in a PostgreSQL trigger?
✗ Incorrect
OLD holds the old row data before an update or delete.
In which trigger event can you use
NEW?✗ Incorrect
NEW is available in INSERT and UPDATE triggers, not DELETE.
What happens if you try to use
NEW in a DELETE trigger?✗ Incorrect
NEW is not defined in DELETE triggers and causes an error if accessed.
Which of these is true about
OLD in triggers?✗ Incorrect
OLD is available in UPDATE and DELETE triggers.
How do you refer to the
name column of the new row in a trigger?✗ Incorrect
NEW.name accesses the name column of the new row.
Explain the difference between
NEW and OLD in PostgreSQL triggers.Think about when rows are created, changed, or deleted.
You got /4 concepts.
Describe when you can access
NEW and when you can access OLD in trigger functions.Consider the lifecycle of a row during different operations.
You got /4 concepts.