<div id="docs-body">
 <div class="chapter">
  <div class="titlepage">
   <div>
    <div>
     <h1 class="title">
      <a name="stored-objects">
      </a>
      Chapter 27 Stored Objects
     </h1>
    </div>
   </div>
  </div>
  <div class="toc">
   <p>
    <b>
     Table of Contents
    </b>
   </p>
   <dl class="toc">
    <dt>
     <span class="section">
      <a href="stored-programs-defining.html">
       27.1 Defining Stored Programs
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="stored-routines.html">
       27.2 Using Stored Routines
      </a>
     </span>
    </dt>
    <dd>
     <dl>
      <dt>
       <span class="section">
        <a href="stored-routines-syntax.html">
         27.2.1 Stored Routine Syntax
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="stored-routines-privileges.html">
         27.2.2 Stored Routines and MySQL Privileges
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="stored-routines-metadata.html">
         27.2.3 Stored Routine Metadata
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="stored-routines-last-insert-id.html">
         27.2.4 Stored Procedures, Functions, Triggers, and LAST_INSERT_ID()
        </a>
       </span>
      </dt>
     </dl>
    </dd>
    <dt>
     <span class="section">
      <a href="triggers.html">
       27.3 Using Triggers
      </a>
     </span>
    </dt>
    <dd>
     <dl>
      <dt>
       <span class="section">
        <a href="trigger-syntax.html">
         27.3.1 Trigger Syntax and Examples
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="trigger-metadata.html">
         27.3.2 Trigger Metadata
        </a>
       </span>
      </dt>
     </dl>
    </dd>
    <dt>
     <span class="section">
      <a href="event-scheduler.html">
       27.4 Using the Event Scheduler
      </a>
     </span>
    </dt>
    <dd>
     <dl>
      <dt>
       <span class="section">
        <a href="events-overview.html">
         27.4.1 Event Scheduler Overview
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="events-configuration.html">
         27.4.2 Event Scheduler Configuration
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="events-syntax.html">
         27.4.3 Event Syntax
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="events-metadata.html">
         27.4.4 Event Metadata
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="events-status-info.html">
         27.4.5 Event Scheduler Status
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="events-privileges.html">
         27.4.6 The Event Scheduler and MySQL Privileges
        </a>
       </span>
      </dt>
     </dl>
    </dd>
    <dt>
     <span class="section">
      <a href="views.html">
       27.5 Using Views
      </a>
     </span>
    </dt>
    <dd>
     <dl>
      <dt>
       <span class="section">
        <a href="view-syntax.html">
         27.5.1 View Syntax
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="view-algorithms.html">
         27.5.2 View Processing Algorithms
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="view-updatability.html">
         27.5.3 Updatable and Insertable Views
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="view-check-option.html">
         27.5.4 The View WITH CHECK OPTION Clause
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="view-metadata.html">
         27.5.5 View Metadata
        </a>
       </span>
      </dt>
     </dl>
    </dd>
    <dt>
     <span class="section">
      <a href="stored-objects-security.html">
       27.6 Stored Object Access Control
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="stored-programs-logging.html">
       27.7 Stored Program Binary Logging
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="stored-program-restrictions.html">
       27.8 Restrictions on Stored Programs
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="view-restrictions.html">
       27.9 Restrictions on Views
      </a>
     </span>
    </dt>
   </dl>
  </div>
  <a class="indexterm" name="idm46045082643312">
  </a>
  <a class="indexterm" name="idm46045082642240">
  </a>
  <a class="indexterm" name="idm46045082641168">
  </a>
  <a class="indexterm" name="idm46045082640096">
  </a>
  <a class="indexterm" name="idm46045082638608">
  </a>
  <a class="indexterm" name="idm46045082637120">
  </a>
  <a class="indexterm" name="idm46045082635632">
  </a>
  <a class="indexterm" name="idm46045082634560">
  </a>
  <a class="indexterm" name="idm46045082633488">
  </a>
  <a class="indexterm" name="idm46045082632416">
  </a>
  <p>
   This chapter discusses stored database objects that are defined in
    terms of SQL code that is stored on the server for later execution.
  </p>
  <p>
   Stored objects include these object types:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Stored procedure: An object created with
      <a class="link" href="create-procedure.html" title="15.1.17 CREATE PROCEDURE and CREATE FUNCTION Statements">
       <code class="literal">
        CREATE PROCEDURE
       </code>
      </a>
      and invoked
        using the
      <a class="link" href="call.html" title="15.2.1 CALL Statement">
       <code class="literal">
        CALL
       </code>
      </a>
      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.
     </p>
    </li>
    <li class="listitem">
     <p>
      Stored function: An object created with
      <a class="link" href="create-function.html" title="15.1.14 CREATE FUNCTION Statement">
       <code class="literal">
        CREATE FUNCTION
       </code>
      </a>
      and used much
        like a built-in function. You invoke it in an expression and it
        returns a value during expression evaluation.
     </p>
    </li>
    <li class="listitem">
     <p>
      Trigger: An object created with
      <a class="link" href="create-trigger.html" title="15.1.22 CREATE TRIGGER Statement">
       <code class="literal">
        CREATE
        TRIGGER
       </code>
      </a>
      that is associated with a table. A trigger is
        activated when a particular event occurs for the table, such as
        an insert or update.
     </p>
    </li>
    <li class="listitem">
     <p>
      Event: An object created with
      <a class="link" href="create-event.html" title="15.1.13 CREATE EVENT Statement">
       <code class="literal">
        CREATE
        EVENT
       </code>
      </a>
      and invoked by the server according to schedule.
     </p>
    </li>
    <li class="listitem">
     <p>
      View: An object created with
      <a class="link" href="create-view.html" title="15.1.23 CREATE VIEW Statement">
       <code class="literal">
        CREATE
        VIEW
       </code>
      </a>
      that when referenced produces a result set. A
        view acts as a virtual table.
     </p>
    </li>
   </ul>
  </div>
  <p>
   Terminology used in this document reflects the stored object
    hierarchy:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Stored routines include stored procedures and functions.
     </p>
    </li>
    <li class="listitem">
     <p>
      Stored programs include stored routines, triggers, and events.
     </p>
    </li>
    <li class="listitem">
     <p>
      Stored objects include stored programs and views.
     </p>
    </li>
   </ul>
  </div>
  <p>
   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:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      For each object type, there are
      <code class="literal">
       CREATE
      </code>
      ,
      <code class="literal">
       ALTER
      </code>
      , and
      <code class="literal">
       DROP
      </code>
      statements
        that control which objects exist and how they are defined. See
      <a class="xref" href="sql-data-definition-statements.html" title="15.1 Data Definition Statements">
       Section 15.1, “Data Definition Statements”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      The
      <a class="link" href="call.html" title="15.2.1 CALL Statement">
       <code class="literal">
        CALL
       </code>
      </a>
      statement is used to
        invoke stored procedures. See
      <a class="xref" href="call.html" title="15.2.1 CALL Statement">
       Section 15.2.1, “CALL Statement”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      Stored program definitions include a body that may use compound
        statements, loops, conditionals, and declared variables. See
      <a class="xref" href="sql-compound-statements.html" title="15.6 Compound Statement Syntax">
       Section 15.6, “Compound Statement Syntax”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      Metadata changes to objects referred to by stored programs are
        detected and cause automatic reparsing of the affected
        statements when the program is next executed. For more
        information, see
      <a class="xref" href="statement-caching.html" title="10.10.3 Caching of Prepared Statements and Stored Programs">
       Section 10.10.3, “Caching of Prepared Statements and Stored Programs”
      </a>
      .
     </p>
    </li>
   </ul>
  </div>
 </div>
 <br/>
</div>
