Documentation Home
MySQL 8.0 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 43.3Mb
PDF (A4) - 43.4Mb
Man Pages (TGZ) - 297.3Kb
Man Pages (Zip) - 402.5Kb
Info (Gzip) - 4.3Mb
Info (Zip) - 4.3Mb
Excerpts from this Manual

MySQL 8.0 Reference Manual  /  Stored Objects

Chapter 27 Stored Objects

Table of Contents

27.1 Defining Stored Programs
27.2 Using Stored Routines
27.2.1 Stored Routine Syntax
27.2.2 Stored Routines and MySQL Privileges
27.2.3 Stored Routine Metadata
27.2.4 Stored Procedures, Functions, Triggers, and LAST_INSERT_ID()
27.3 Using Triggers
27.3.1 Trigger Syntax and Examples
27.3.2 Trigger Metadata
27.4 Using the Event Scheduler
27.4.1 Event Scheduler Overview
27.4.2 Event Scheduler Configuration
27.4.3 Event Syntax
27.4.4 Event Metadata
27.4.5 Event Scheduler Status
27.4.6 The Event Scheduler and MySQL Privileges
27.5 Using Views
27.5.1 View Syntax
27.5.2 View Processing Algorithms
27.5.3 Updatable and Insertable Views
27.5.4 The View WITH CHECK OPTION Clause
27.5.5 View Metadata
27.6 Stored Object Access Control
27.7 Stored Program Binary Logging
27.8 Restrictions on Stored Programs
27.9 Restrictions on Views

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:

  • Stored procedure: An object created withCREATE PROCEDURE and invoked using theCALL 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.

  • Stored function: An object created withCREATE FUNCTION and used much like a built-in function. You invoke it in an expression and it returns a value during expression evaluation.

  • Trigger: An object created withCREATE 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.

  • Event: An object created withCREATE EVENT and invoked by the server according to schedule.

  • View: An object created withCREATE 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.

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: