简体   繁体   English

MySQL中的存储过程与触发器

[英]Stored Procedures vs Triggers in MySQL

在MySQL世界中,STORED PROCEDURES如何与TRIGGERS不同?

Stored procedures are stored as precompilated code (stored routine) and called by the programmer wherever it wants to fire. 存储过程存储为预编译代码(存储例程),并由程序员在任何需要触发的位置调用。 Stored procedure can return value(s). 存储过程可以返回值。 About procedures and functions. 关于程序和功能。

Triggers are named database objects fired automatically when insert, delete, update (or other event) occurred, there can be no explicit invocation. 触发器是在发生插入,删除,更新(或其他事件)时自动触发的命名数据库对象,不能进行显式调用。 Trigger can not return any data. 触发器无法返回任何数据。 About triggers. 关于触发器。

You can use procedures in trigger's code. 您可以在触发器代码中使用过程。

A trigger is a type of stored procedure, but it runs based off of an event on a table instead of just being a set of instructions to be executed repeatedly. 触发器是一种存储过程,但它基于表上的事件而不是仅仅是要重复执行的一组指令来运行。

A trigger is defined to activate when an INSERT, DELETE, or UPDATE statement executes for the associated table. 触发器定义为在为关联表执行INSERT,DELETE或UPDATE语句时激活。

A stored procedure is a group of Transact-SQL statements compiled into a single execution plan. 存储过程是一组编译为单个执行计划的Transact-SQL语句。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM