我可以在 mysql 中的 select 语句上启动触发器吗? [英] Can I launch a trigger on select statement in mysql?

查看:58
本文介绍了我可以在 mysql 中的 select 语句上启动触发器吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次我 SELECT 时,我都试图在表 X 上运行一个 INSERT 语句,无论如何我只能使用 MySQL 来完成表 Y 中的任何记录吗?

I am trying to run an INSERT statement on table X each time I SELECT any record from table Y is there anyway that I can accomplish that using MySQL only?

触发器之类的东西?

推荐答案

简短的回答是否定的.触发器是用 INSERTUPDATEDELETE代码>.

Short answer is No. Triggers are triggered with INSERT, UPDATE or DELETE.

可能的解决方案.相当罕见的场景:

Possible solution for this. rather rare scenario:

  • 首先写一些存储过程做你想要的 SELECTs表 X.
  • 然后,限制所有用户只能使用这些存储过程并没有允许他们直接在 table 上使用 SELECTX.
  • 然后将存储过程更改为还调用一个存储过程执行您想要的操作(INSERT 或其他).
  • First, write some stored procedures that do the SELECTs you want on table X.
  • Then, restrict all users to use only these stored procedures and do not allow them to directly use SELECT on table X.
  • Then alter the stored procedures to also call a stored procedure that performs the action you want (INSERT or whatever).

这篇关于我可以在 mysql 中的 select 语句上启动触发器吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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