Write a SQL query to audit user access to sensitive data using triggers.Solution:-- Create a trigger to log access to sensitive data. CREATE TRIGGER LogSensitiveAccess ON Employees FOR SELECT AS BEGIN INSERT INTO AccessLog (UserName, TableName, AccessTime) VALUES (SYSTEM_USER, 'Employees',...
Example: Using Triggers with Python Code: importsqlite3# Import the sqlite3 library# Connect to SQLite database (or create it if it doesn't exist)connection=sqlite3.connect("example.db")# Create a cursor object to execute SQL queriescursor=connection.cursor()# Create a sample tablecursor.ex...
Write a code in PL/SQL to create a trigger that restricts the insertion of new rows if the total of a column's values exceeds a certain threshold. Sample Solution: PL/SQL Code: -- Create the orders tableCREATETABLEorders(order_id NUMBERPRIMARYKEY,customer_id NUMBER,order_amount NUMBER);-...