除非指定了主键,否则防止从表中删除* [英] prevent delete * from table unless primary key specified

查看:127
本文介绍了除非指定了主键,否则防止从表中删除*的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想防止用户使用从表中删除*,除非指定了主键,所以我们的团队成员之一希望使用从表名中删除*",我希望以后避免这种情况.

I want to prevent user from using deleting * from table unless primary key specified, one of our team member accendently used "delete * from table_name" i want to prevent such scenarios in future.

推荐答案

Would safe updates be viable for you? This is an option you can enable on the command line, in the option file or set a variable in SQL code that prevents updates and deletes without a where clause that includes the key columns defining the rows to change.

在MySQL Workbench中,Preferences -> SQL Editor -> Safe Updates (rejects UPDATEs and DELETEs with no restriction)中有一个设置.我相信默认情况下它甚至是启用的.

In MySQL Workbench there is a setting in Preferences -> SQL Editor -> Safe Updates (rejects UPDATEs and DELETEs with no restriction). I believe this is even on by default.

这篇关于除非指定了主键,否则防止从表中删除*的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆