Can I launch a trigger on select statement in mysql?(我可以在 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?
触发器之类的东西?
推荐答案
简短的回答是否定的.触发器是用 INSERT、UPDATE 或 DELETE触发的代码>.
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
SELECTon table X. - Then alter the stored procedures to
also call a stored procedure that
performs the action you want
(
INSERTor whatever).
这篇关于我可以在 mysql 中的 select 语句上启动触发器吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:我可以在 mysql 中的 select 语句上启动触发器吗?
基础教程推荐
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- oracle区分大小写的原因? 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- 在多列上分布任意行 2021-01-01
