Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MYSQL trigger

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Create a table CREATE TABLE cmd (id INT PRIMARY KEY auto_increment, USER CHAR (32), priv CHAR (10), cmd CHAR (64), sub_time datetime, # submission time success enum ('yes',' no') # 0 for execution failure); create a table CREATE TABLE errlog (id INT PRIMARY KEY auto_increment, err_id int) to be triggered Create a trigger delimiter $$#; convert it to $$, and let the following code run CREATE TRIGGER tri_after_insert_cmd AFTER INSERT ON cmd FOR EACH ROWBEGIN if NEW.success = 'no' then # NEW (new information, that is, insert cmd information) insert into errlog (err_id) values (NEW.id); # insert syntax. When the above condition holds, end if;END $$# makes the trigger delimiter; # restores the symbol to Insert data INSERT INTO cmd (USER, priv, cmd, sub_time, success) VALUES ('egon','0755','ls-l / etc',NOW (),' yes'), ('egon','0755','cat / etc/passwd',NOW (),' no'), ('egon','0755','useradd xxx',NOW (),' no') ('egon','0755','ps aux',NOW (),' yes') Delete trigger drop trigger tri_after_insert_cmd

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report