未经SELECT许可,如何更新特定记录? [英] How can I update a specific record without SELECT permission?

查看:114
本文介绍了未经SELECT许可,如何更新特定记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想执行以下操作:

  UPDATE grades SET status="pass" WHERE recno=123;

但是,我希望进行更新的用户帐户具有对数据库的只写访问权限,这意味着它没有SELECT访问权限.这将导致WHERE子句失败.

However, I want the user account doing the update to have write-only access to the database which means it does not have SELECT access. This causes the WHERE clause to fail.

如有必要,我实际上可以重写整个记录,但是recno是主键,这将导致写入失败.有办法吗

If necessary, I can actually re-write the entire record, but recno is the primary key, which would cause the write to fail. Is there a way to do

INSERT INTO grades (recno,name,status,...) VALUES (123, 'chemistry', 'pass',...)
  ON DUPLICATE KEY UPDATE <everything>;

还是这是错误的方法?此外,这不是解决更新特定记录中的特定字段"问题的通用解决方案.

or is this the wrong approach? Besides, it's not the general solution to the "update a specific field in a specific record" problem.

推荐答案

这是保护表的一种特殊方法.在某些情况下,这可能是有道理的,尽管通常情况下,您希望提供一些可见性窗口,以使用户不会对数据的影响视而不见.

That is a peculiar way to protect a table. It might make sense in some cases, though usually you want to provide some window of visibility so users are not blind to their effects on data.

要完全实现只写数据库,请使用存储过程.这些过程可以完全访问数据库,并且只能授予用户访问存储过程的权限.

To completely implement a write-only database, use stored procedures. The procedures can have full access to the database, and users can be granted access only to stored procedures.

这篇关于未经SELECT许可,如何更新特定记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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