1.

What is a Trigger? Name some instances when “Triggers” can be used.

Answer»
  • As the name indicates, ‘Trigger’ means to ‘activate’ something. In the case of PL/SQL, a trigger is a stored procedure that SPECIFIES what action has to be taken by the database when an event related to the database is performed.
  • Syntax:
TRIGGER trigger_name trigger_event [ restrictions ]BEGIN actions_of_trigger;END;

In the above syntax, if the trigger_name the trigger is in the enabled state, the trigger_event causes the database to FIRE actions_of_trigger if the restrictions are TRUE or unavailable.

  • They are mainly used in the following scenarios:
    • In order to maintain COMPLEX integrity constraints.
    • For the purpose of auditing any table information.
    • Whenever changes are done to a table, if we need to signal other actions UPON completion of the change, then we use triggers.
    • In order to enforce complex rules of business.
    • It can also be used to prevent invalid transactions.
  • You can refer https://docs.oracle.com/database/121/TDDDG/tdddg_triggers.htm for more information regarding triggers.


Discussion

No Comment Found