0
0
PostgreSQLquery~5 mins

Trigger for audit logging in PostgreSQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a trigger in PostgreSQL?
A trigger is a special function that automatically runs when certain events happen on a table, like insert, update, or delete.
Click to reveal answer
beginner
Why use triggers for audit logging?
Triggers help record changes automatically in an audit table whenever data changes, so you can track who changed what and when.
Click to reveal answer
beginner
What event types can a trigger listen to for audit logging?
Triggers can listen to INSERT, UPDATE, and DELETE events to capture data changes for auditing.
Click to reveal answer
beginner
What is the purpose of an audit table in PostgreSQL?
An audit table stores records of changes made to data, including old and new values, who made the change, and when it happened.
Click to reveal answer
intermediate
How do you create a trigger function for audit logging in PostgreSQL?
You write a PL/pgSQL function that inserts a record into the audit table whenever a data change event occurs.
Click to reveal answer
Which PostgreSQL event can a trigger NOT listen to for audit logging?
ADELETE
BUPDATE
CSELECT
DINSERT
What language is commonly used to write trigger functions in PostgreSQL?
APL/pgSQL
BPython
CJavaScript
DBash
What is the main purpose of an audit trigger?
ATo delete old data
BTo automatically backup the database
CTo speed up queries
DTo log changes made to data
Which of these is NOT typically stored in an audit log?
ADatabase server uptime
BNew data values
COld data values
DUser who made the change
How do you attach a trigger function to a table in PostgreSQL?
AUsing CREATE FUNCTION statement
BUsing CREATE TRIGGER statement
CUsing ALTER TABLE statement
DUsing INSERT INTO statement
Explain how a trigger can be used to implement audit logging in PostgreSQL.
Think about what happens when data changes and how to capture that automatically.
You got /3 concepts.
    Describe the steps to create an audit logging system using triggers in PostgreSQL.
    Start with where to store logs, then how to capture changes, and finally how to connect them.
    You got /3 concepts.