8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

MySQL 8.4 参考手册 / 27 存储对象
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

第 27 章 存储对象Chapter 27 Stored Objects

本章讨论以 SQL 代码定义并存储在服务器上以供以后执行的数据库存储对象。This chapter discusses stored database objects that are defined in terms of SQL code that is stored on the server for later execution.

存储对象包括以下对象类型:Stored objects include these object types:

  • 存储过程:使用 CREATE PROCEDURE 创建的对象,并使用 CALL 语句调用。过程没有返回值,但可以修改其参数以便调用者稍后查看。它还可以生成要返回给客户端程序的结果集。Stored procedure: An object created with CREATE PROCEDURE and invoked using the CALL statement. A procedure does not have a return value but can modify its parameters for later inspection by the caller. It can also generate result sets to be returned to the client program.

  • 存储函数:使用 CREATE FUNCTION 创建的对象,使用起来类似内置函数。您可以在表达式中调用它,并且在表达式求值过程中返回一个值。Stored function: An object created with CREATE FUNCTION and used much like a built-in function. You invoke it in an expression and it returns a value during expression evaluation.

  • 触发器:使用CREATE TRIGGER 创建并与表关联的对象。当表发生特定事件(例如插入或更新)时,触发器会被激活。Trigger: An object created with CREATE TRIGGER that is associated with a table. A trigger is activated when a particular event occurs for the table, such as an insert or update.

  • 事件:使用CREATE EVENT 创建的对象,并由服务器根据计划调用。Event: An object created with CREATE EVENT and invoked by the server according to schedule.

  • 视图:使用CREATE VIEW 创建的对象,当引用时生成结果集。视图充当虚拟表。View: An object created with CREATE VIEW that when referenced produces a result set. A view acts as a virtual table.

本文档使用的术语反映了存储对象的层级结构:Terminology used in this document reflects the stored object hierarchy:

  • 存储例程包括存储过程和函数。Stored routines include stored procedures and functions.

  • 存储程序包括存储例程、触发器和事件。Stored programs include stored routines, triggers, and events.

  • 存储对象包括存储程序和视图。Stored objects include stored programs and views.

本章介绍如何使用存储对象。以下各节提供有关与这些对象相关的 SQL 语法以及对象处理的附加信息:This chapter describes how to use stored objects. The following sections provide additional information about SQL syntax for statements related to these objects, and about object processing: