0
0
PostgreSQLquery~5 mins

NEW and OLD record access in PostgreSQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
ANEW
BOLD
CCURRENT
DPREVIOUS
In which trigger event can you use NEW?
ANONE
BDELETE
CTRUNCATE
DUPDATE
What happens if you try to use NEW in a DELETE trigger?
AIt causes an error
BIt returns the deleted row
CIt returns NULL
DIt returns the new row
Which of these is true about OLD in triggers?
AAvailable in UPDATE and DELETE triggers
BAvailable in INSERT and UPDATE triggers
CAvailable only in INSERT triggers
DNever available
How do you refer to the name column of the new row in a trigger?
AOLD.name
BCURRENT.name
CNEW.name
DROW.name
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.