What are the two virtual tables available at the time of database trigger execution?

Table columns are referred as THEN.column_name and NOW.column_name.

For INSERT related triggers, NOW.column_name values are available only.

For DELETE related triggers, THEN.column_name values are available only.

For UPDATE related triggers, both Table columns are available.

In PL/SQL, when a database trigger is executed, two special virtual tables are available: OLD and NEW. These tables are used in the context of row-level triggers (like BEFORE INSERT, BEFORE UPDATE, BEFORE DELETE, AFTER INSERT, AFTER UPDATE, and AFTER DELETE) to access the old and new values of the affected rows.

  • OLD: Represents the old values of the rows being affected by the triggering statement. This is applicable for BEFORE UPDATE and BEFORE DELETE triggers.
  • NEW: Represents the new values that will be assigned to the rows being affected by the triggering statement. This is applicable for BEFORE INSERT and BEFORE UPDATE triggers.

These virtual tables allow you to reference the values of columns before and after the triggering event, making it possible to perform actions based on these values within the trigger code.