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

Restrict SSH and Allow with SFTP

Create SFTP user:  ``` sudo useradd -M -s /sbin/nologin sftpuser sudo passwd sftpuser ``` Add below lines into, /etc/ssh/sshd_config ``` Mat...