EACH is not a stand-alone command but a reserved word that appears inside the FOR EACH ROW clause of CREATE TRIGGER. When a trigger is declared FOR EACH ROW, the database executes the trigger body separately for every row inserted, updated, or deleted, rather than once per statement. This enables row-by-row auditing, validation, denormalized updates, and other fine-grained logic. If EACH is omitted (or FOR EACH STATEMENT is specified), the trigger fires only once per DML statement, regardless of the number of affected rows. Some dialects, notably Google BigQuery legacy SQL, also used EACH in JOIN EACH or SELECT EACH to control sharding behavior, but that usage is deprecated. The modern, widely supported context for EACH is strictly within trigger definitions.
CREATE TRIGGER, FOR EACH STATEMENT, BEFORE trigger, AFTER trigger, INSTEAD OF trigger, NEW and OLD pseudorecords
SQL:1999 (trigger feature)
FOR EACH ROW runs the trigger once per row, giving access to NEW and OLD values. FOR EACH STATEMENT fires only once after the statement finishes and cannot access row data.
Yes. BEFORE row triggers can modify NEW values before they are written. AFTER row triggers can only read the data because the change has already occurred.
Row-level triggers add overhead proportional to the number of affected rows. For bulk operations consider statement-level triggers or ETL processes to keep performance acceptable.
No. Google BigQuery Standard SQL removed JOIN EACH. Modern queries should omit EACH and rely on the optimizer to handle large joins.