8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

15.6.4 存储程序15.6.4 Variables in Stored Programs

系统变量以及用户自定义变量可以在存储程序中使用,就像它们也可以在存储程序上下文之外使用一样。此外,存储程序可以使用 DECLARE 来定义本地变量,存储例程(过程和函数)也可以声明,以获取在例程与调用者之间传递数值的参数。System variables and user-defined variables can be used in stored programs, just as they can be used outside stored-program context. In addition, stored programs can use DECLARE to define local variables, and stored routines (procedures and functions) can be declared to take parameters that communicate values between the routine and its caller.

有关局部变量的作用域及 MySQL 如何解决歧义名称的信息,请参见 第 15.6.4.2 节,”局部变量作用域与解析“。For information about the scope of local variables and how MySQL resolves ambiguous names, see Section 15.6.4.2, “Local Variable Scope and Resolution”.

不允许将 DEFAULT给存储过程、函数参数或存储程序的本地变量(例如 SET var_name = DEFAULT 语句)。在 MySQL 8.4 中,这会导致语法错误。It is not permitted to assign the value DEFAULT to stored procedure or function parameters or stored program local variables (for example with a SET var_name = DEFAULT statement). In MySQL 8.4, this results in a syntax error.