MYSQL数据库防止mysql表被清空的方法详解
《MYSQL数据库防止mysql表被清空的方法详解》要点: 为阻止用户删除或清空表以及数据,给他少量的权限即可. create role t_girl=# alter schema ytt owner to ytt3; alter schema t_girl=# grant select on all tables in schema ytt to ytt3; grant 现在用新用户ytt3登陆并且执行truncate,发现被禁止. psql (9.3.4) type "help" for help. t_girl=> truncate table j2; error: permission denied for relation j2 当测试时,一般来说,管理员为了方便懒得去分配各种各样细的权限. 创建一个基于语句的触发器就可以: t_girl=# sf prevent_truncate t_girl=# d j2 t_girl=#MYSQL教程 t_girl=# truncate table j2; 这种方法也只是对于提供了这项功能的数据库才ok. 比如mysql的触发器只提供了基于行的操作,那么语句的操作就不能触发了. error 1142 (42000): drop command denied to user 'ytt3'@'localhost' for table 'j2' 要么,就对数据库的操作用sproc封装起来, | error | +------------------------------------+ | prevent t_girl.j2 to be truncated! | +------------------------------------+ 1 row in set (0.00 sec) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |