Stored Procedures vs Triggers in MySQL

后端 未结 2 971
我寻月下人不归
我寻月下人不归 2021-01-19 17:59

How are STORED PROCEDURES different than TRIGGERS in the MySQL world ?

相关标签:
2条回答
  • 2021-01-19 18:42

    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.

    0 讨论(0)
  • 2021-01-19 19:03

    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.

    A stored procedure is a group of Transact-SQL statements compiled into a single execution plan.

    0 讨论(0)
提交回复
热议问题