What are triggers, and when would you use them?

Answer Posted / nashiinformaticssolutions

A trigger is a block of PL/SQL code automatically executed in response to certain events (e.g., INSERT, UPDATE, DELETE) on a table.
Example Trigger:
CREATE OR REPLACE TRIGGER EmployeeAudit
AFTER INSERT ON employees
FOR EACH ROW
BEGIN
INSERT INTO audit_log(employee_id, action, action_date)
VALUES (:NEW.id, 'INSERT', SYSDATE);
END;

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the usage of nvl function?

773


What is nvarchar in sql?

717


What is sql*loader?

759


What does over partition by mean in sql?

711


explain the advantages and disadvantages of stored procedure? : Sql dba

718






Explain raise_application_error.

834


What are different types of tables in sql?

700


what is a composite primary key ? : Sql dba

782


What does subquery mean in sql?

741


Does postgresql run on the cloud?

800


What does desc stand for?

790


What are all the common sql functions?

751


What is difference between inner join and self join?

782


Can we group by two columns in sql?

731


What does an inner join do?

788