Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following security trigger - - Table for logging delete attempts CREATE TABLE audit _ log ( event _ id SERIAL PRIMARY KEY, event

Consider the following security trigger
-- Table for logging delete attempts
CREATE TABLE audit_log (
event_id SERIAL PRIMARY KEY,
event_time TIMESTAMP NOT NULL,
username TEXT NOT NULL,
table_name TEXT NOT NULL,
action_taken TEXT NOT NULL
;
-- Trigger function to log delete attempts
CREATE OR REPLACE FUNCTION log_delete_attempt ()
RETURNS TRIGGER AS $$
BEGIN
INSERT INTO audit_log(event_time, username, table_name, action_taken)
VALUES (now (), CURRENT_USER, TG_TABLE_NAME, 'DELETE ATTEMPT');
RETURN OLD;
END;
$$ LANGUAGE plpgsql;
-- Trigger for delete attempts on sensitive table 'customer_data'
CREATE TRIGGER trigger_log_delete
BEFORE DELETE ON customer_data
FOR EACH ROW EXECUTE FUNCTION log_delete_attempt();
What does the audit_log table store?
Every login attempt by a user
Attempts to delete rows from the customer_data table
Every change to the database schema
All the INSERT operations in the database
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions