advancedTop 30 Scenario-Based Questions
You need to implement full audit logging for all DML on the orders table in PostgreSQL. How?
Trigger-based audit: CREATE TABLE orders_audit (audit_id BIGSERIAL, operation CHAR(1), changed_by TEXT, changed_at TIMESTAMP, old_data JSONB, new_data JSONB); CREATE OR REPLACE FUNCTION log_orders_audit() RETURNS TRIGGER AS [func_body] CREATE TRIGGER orders_audit_trigger AFTER INSERT OR UPDATE OR DELETE ON orders FOR EACH ROW EXECUTE FUNCTION log_orders_audit(). In trigger body: operation = TG_OP[
This is a Pro chapter
Sign in, then upgrade to Pro or Power to unlock this and the full Databases Mastery library.
You need to implement full audit logging for all DML on the orders table in PostgreSQL. How?