8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

MySQL 8.4 参考手册 / 27 存储对象 / 27.2 使用存储的例程 / 27.2.4 存储过程、函数、触发器和 LAST_INSERT_ID()
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

27.2.4 存储过程、函数、触发器和 LAST_INSERT_ID()27.2.4 Stored Procedures, Functions, Triggers, and LAST_INSERT_ID()

在存储例程(存储过程或函数)或触发器的主体中,LAST_INSERT_ID() 的值的变化方式与在这些对象主体外执行语句时相同(参见 第 14.15 节,“信息函数”)。存储例程或触发器对 LAST_INSERT_ID() 值的影响,后续语句看到的结果取决于例程的类型:Within the body of a stored routine (procedure or function) or a trigger, the value of LAST_INSERT_ID() changes the same way as for statements executed outside the body of these kinds of objects (see Section 14.15, “Information Functions”). The effect of a stored routine or trigger upon the value of LAST_INSERT_ID() that is seen by following statements depends on the kind of routine:

  • 如果存储过程执行会改变 LAST_INSERT_ID() 值的语句,则在调用该过程后,随后的语句将看到被更改的值。If a stored procedure executes statements that change the value of LAST_INSERT_ID(), the changed value is seen by statements that follow the procedure call.

  • 对于更改该值的存储函数和触发器,当函数或触发器结束时,值会恢复,因此后续语句不会看到已更改的值。For stored functions and triggers that change the value, the value is restored when the function or trigger ends, so following statements do not see a changed value.