mysql触发器-记录更改用户信息

xiaoxiao2021-03-01  20

begin declare ip,writedate varchar(2000); declare nowip varchar; declare nowuser varchar; declare nowinfo varchar; #使用游标记录当前连接数据库的ip地址 declare _ipCursor CURSOR FOR SELECT `USER`,`HOST`,INFO FROM information_schema.`PROCESSLIST`; DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET _done = 1; #打开游标 OPEN _ipCursor; WHILE _done<>1 DO #从游标中获取用户、ip、info信息 FETCH _ipCursor INTO nowuser,nowip,nowinfo; ip+=nowuser+"-"+nowip+"-"+nowinfo; END WHILE; CLOSE _ipCursor; if (NEW.User_Password<>OLD.User_Password) then insert into T_USERT_PASSWORDCHANGE_RECORD (IP,DATE,PASSWORD_BEFORE,PASSWORD_AFTER,USER_NAME,USER_ID) values (ip,now(),OLD.User_Password,NEW.User_Password,NEW.User_Name,NEW.User_ID); end if; end

转载请注明原文地址: https://www.6miu.com/read-3850295.html

最新回复(0)