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 语句上启动触发器吗?
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 更改自动增量起始编号? 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- SQL 临时表问题 2022-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
