0
0
PostgreSQLquery~10 mins

AFTER trigger behavior in PostgreSQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create an AFTER INSERT trigger on the table 'orders'.

PostgreSQL
CREATE TRIGGER after_insert_order
AFTER [1] ON orders
FOR EACH ROW EXECUTE FUNCTION log_order_insert();
Drag options to blanks, or click blank then click option'
ADELETE
BTRUNCATE
CINSERT
DUPDATE
Attempts:
3 left
💡 Hint
Common Mistakes
Using UPDATE instead of INSERT for an insert trigger.
Confusing BEFORE and AFTER triggers.
2fill in blank
medium

Complete the code to specify the timing of the trigger as AFTER.

PostgreSQL
CREATE TRIGGER update_log
[1] UPDATE ON customers
FOR EACH ROW EXECUTE FUNCTION log_update();
Drag options to blanks, or click blank then click option'
AAFTER
BBEFORE
CINSTEAD OF
DDURING
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing BEFORE instead of AFTER.
Using INSTEAD OF which is for views, not tables.
3fill in blank
hard

Fix the error in the trigger creation by choosing the correct keyword for the trigger event.

PostgreSQL
CREATE TRIGGER after_delete_log
AFTER [1] ON employees
FOR EACH ROW EXECUTE FUNCTION log_delete();
Drag options to blanks, or click blank then click option'
AINSERT
BSELECT
CUPDATE
DDELETE
Attempts:
3 left
💡 Hint
Common Mistakes
Using INSERT or UPDATE instead of DELETE.
Trying to create triggers on SELECT events.
4fill in blank
hard

Fill both blanks to create an AFTER UPDATE trigger that fires for each row.

PostgreSQL
CREATE TRIGGER after_update_status
[1] UPDATE ON orders
FOR EACH [2] EXECUTE FUNCTION update_status_log();
Drag options to blanks, or click blank then click option'
AAFTER
BSTATEMENT
CROW
DBEFORE
Attempts:
3 left
💡 Hint
Common Mistakes
Using BEFORE instead of AFTER.
Choosing STATEMENT instead of ROW for per-row triggers.
5fill in blank
hard

Fill all three blanks to create an AFTER DELETE trigger on the 'products' table that fires for each row and calls the correct function.

PostgreSQL
CREATE TRIGGER [1]
[2] DELETE ON products
FOR EACH [3] EXECUTE FUNCTION log_product_delete();
Drag options to blanks, or click blank then click option'
Aafter_delete_product
BAFTER
CROW
DBEFORE
Attempts:
3 left
💡 Hint
Common Mistakes
Using BEFORE instead of AFTER.
Using STATEMENT instead of ROW.
Choosing a wrong trigger name.