Linux Programmer | RHCE | RHCSA

Search This Blog

Friday, 12 November 2021

record delete restriction trigger

DELIMITER $$
CREATE TRIGGER trigger_name
BEFORE DELETE
ON table_name
FOR EACH ROW
BEGIN
    if SUBSTRING_INDEX(USER(),'@',1) NOT IN ('root') THEN
        CALL cannot_delete_error;
    END if;
END
$$

No comments:

Post a Comment

These 15 resources will sharpen you for interviews and real production chaos

  1. Explainshell – paste any bash command, and it breaks it down word by word. No more guessing awk or sed. 2. KubeSim – browser-based Kube...