Complete the code to create a trigger that activates {{BLANK_1}} a row is inserted.
CREATE TRIGGER trg_after_insert
AFTER INSERT ON employees
FOR EACH ROW
BEGIN
-- trigger logic here
END; -- This trigger runs [1] a row is insertedThe trigger is defined as AFTER INSERT, so it runs after a row is inserted.
Complete the code to avoid performance issues by limiting the trigger to run {{BLANK_1}} times per statement.
CREATE TRIGGER trg_bulk_update
AFTER UPDATE ON orders
[1]
BEGIN
-- trigger logic
END;Using FOR EACH STATEMENT makes the trigger run once per statement, improving performance for bulk operations.
Fix the error in the trigger code by choosing the correct keyword for referencing the new row's column value.
CREATE TRIGGER trg_check_salary BEFORE INSERT ON employees FOR EACH ROW BEGIN IF NEW.salary [1] 0 THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Salary must be positive'; END IF; END;
The condition should check if salary is less than 0 to raise an error for negative values.
Fill both blanks to create a trigger that avoids performance issues by limiting the operations inside the trigger to {{BLANK_1}} and using {{BLANK_2}} operators.
CREATE TRIGGER trg_limit_ops AFTER UPDATE ON products FOR EACH ROW BEGIN -- Only [1] operations allowed IF NEW.stock [2] OLD.stock THEN -- update logic END IF; END;
Keeping trigger operations simple and using straightforward comparisons like '>' helps maintain good performance.
Fill all three blanks to optimize trigger performance by avoiding {{BLANK_1}}, minimizing {{BLANK_2}}, and using {{BLANK_3}} triggers when possible.
CREATE TRIGGER trg_optimize BEFORE INSERT ON sales FOR EACH ROW BEGIN -- Avoid [1] -- Minimize [2] -- Prefer [3] triggers END;
To keep triggers fast, avoid heavy computations and nested queries, and prefer statement-level triggers when possible.