hue審計記錄-記錄用戶的查詢記錄(用戶前端刪除,后端也不會刪除)


 原來用戶執行sql會存儲在desktop_document2表中,用戶可以在前端界面對其進行刪除,為了優化審計,建立一個新表desktop_document2_history,並建立一個觸發器,實時更新。

添加一個觸發器,記錄所有用戶的執行sql

DROP TABLE IF EXISTS `desktop_document2_history`;
CREATE TABLE `desktop_document2_history` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `desktop_document2_id` bigint(20) NOT NULL,
  `owner_id` bigint(20) NOT NULL,
  `create_time` datetime  NOT NULL,
  `search` longtext,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


DROP TRIGGER IF EXISTS `tri_update_desktop_document2`;
DELIMITER ;;
CREATE TRIGGER `tri_update_desktop_document2` 
AFTER UPDATE ON `desktop_document2` FOR EACH ROW begin
    INSERT INTO desktop_document2_history
         (desktop_document2_id,owner_id,create_time, search) VALUES (new.id,new.owner_id, new.last_modified, new.search);
end
;;
DELIMITER ;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM