<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="view-updatability">
      </a>
      27.5.3 Updatable and Insertable Views
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045081825936">
  </a>
  <a class="indexterm" name="idm46045081824896">
  </a>
  <a class="indexterm" name="idm46045081823408">
  </a>
  <a class="indexterm" name="idm46045081821920">
  </a>
  <p>
   Some views are updatable and references to them can be used to
      specify tables to be updated in data change statements. That is,
      you can use them in statements such as
   <a class="link" href="update.html" title="15.2.17 UPDATE Statement">
    <code class="literal">
     UPDATE
    </code>
   </a>
   ,
   <a class="link" href="delete.html" title="15.2.2 DELETE Statement">
    <code class="literal">
     DELETE
    </code>
   </a>
   , or
   <a class="link" href="insert.html" title="15.2.7 INSERT Statement">
    <code class="literal">
     INSERT
    </code>
   </a>
   to update the contents of
      the underlying table. Derived tables and common table expressions
      can also be specified in multiple-table
   <a class="link" href="update.html" title="15.2.17 UPDATE Statement">
    <code class="literal">
     UPDATE
    </code>
   </a>
   and
   <a class="link" href="delete.html" title="15.2.2 DELETE Statement">
    <code class="literal">
     DELETE
    </code>
   </a>
   statements, but can only be
      used for reading data to specify rows to be updated or deleted.
      Generally, the view references must be updatable, meaning that
      they may be merged and not materialized. Composite views have more
      complex rules.
  </p>
  <p>
   For a view to be updatable, there must be a one-to-one
      relationship between the rows in the view and the rows in the
      underlying table. There are also certain other constructs that
      make a view nonupdatable. To be more specific, a view is not
      updatable if it contains any of the following:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Aggregate functions or window functions
          (
      <a class="link" href="aggregate-functions.html#function_sum">
       <code class="literal">
        SUM()
       </code>
      </a>
      ,
      <a class="link" href="aggregate-functions.html#function_min">
       <code class="literal">
        MIN()
       </code>
      </a>
      ,
      <a class="link" href="aggregate-functions.html#function_max">
       <code class="literal">
        MAX()
       </code>
      </a>
      ,
      <a class="link" href="aggregate-functions.html#function_count">
       <code class="literal">
        COUNT()
       </code>
      </a>
      , and so forth)
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       DISTINCT
      </code>
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       GROUP BY
      </code>
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       HAVING
      </code>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="union.html" title="15.2.18 UNION Clause">
       <code class="literal">
        UNION
       </code>
      </a>
      or
      <a class="link" href="union.html" title="15.2.18 UNION Clause">
       <code class="literal">
        UNION ALL
       </code>
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      Subquery in the select list
     </p>
     <p>
      Nondependent subqueries in the select list fail for
      <a class="link" href="insert.html" title="15.2.7 INSERT Statement">
       <code class="literal">
        INSERT
       </code>
      </a>
      , but are okay for
      <a class="link" href="update.html" title="15.2.17 UPDATE Statement">
       <code class="literal">
        UPDATE
       </code>
      </a>
      ,
      <a class="link" href="delete.html" title="15.2.2 DELETE Statement">
       <code class="literal">
        DELETE
       </code>
      </a>
      . For dependent
          subqueries in the select list, no data change statements are
          permitted.
     </p>
    </li>
    <li class="listitem">
     <p>
      Certain joins (see additional join discussion later in this
          section)
     </p>
    </li>
    <li class="listitem">
     <p>
      Reference to nonupdatable view in the
      <code class="literal">
       FROM
      </code>
      clause
     </p>
    </li>
    <li class="listitem">
     <p>
      Subquery in the
      <code class="literal">
       WHERE
      </code>
      clause that refers to
          a table in the
      <code class="literal">
       FROM
      </code>
      clause
     </p>
    </li>
    <li class="listitem">
     <p>
      Refers only to literal values (in this case, there is no
          underlying table to update)
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       ALGORITHM = TEMPTABLE
      </code>
      (use of a temporary
          table always makes a view nonupdatable)
     </p>
    </li>
    <li class="listitem">
     <p>
      Multiple references to any column of a base table (fails for
      <a class="link" href="insert.html" title="15.2.7 INSERT Statement">
       <code class="literal">
        INSERT
       </code>
      </a>
      , okay for
      <a class="link" href="update.html" title="15.2.17 UPDATE Statement">
       <code class="literal">
        UPDATE
       </code>
      </a>
      ,
      <a class="link" href="delete.html" title="15.2.2 DELETE Statement">
       <code class="literal">
        DELETE
       </code>
      </a>
      )
     </p>
    </li>
   </ul>
  </div>
  <a class="indexterm" name="idm46045081781968">
  </a>
  <p>
   A generated column in a view is considered updatable because it is
      possible to assign to it. However, if such a column is updated
      explicitly, the only permitted value is
   <code class="literal">
    DEFAULT
   </code>
   . For information about generated
      columns, see
   <a class="xref" href="create-table-generated-columns.html" title="15.1.20.8 CREATE TABLE and Generated Columns">
    Section 15.1.20.8, “CREATE TABLE and Generated Columns”
   </a>
   .
  </p>
  <p>
   It is sometimes possible for a multiple-table view to be
      updatable, assuming that it can be processed with the
   <code class="literal">
    MERGE
   </code>
   algorithm. For this to work, the view
      must use an inner join (not an outer join or a
   <a class="link" href="union.html" title="15.2.18 UNION Clause">
    <code class="literal">
     UNION
    </code>
   </a>
   ). Also, only a single table
      in the view definition can be updated, so the
   <code class="literal">
    SET
   </code>
   clause must name only columns from one of
      the tables in the view. Views that use
   <a class="link" href="union.html" title="15.2.18 UNION Clause">
    <code class="literal">
     UNION ALL
    </code>
   </a>
   are not
      permitted even though they might be theoretically updatable.
  </p>
  <p>
   With respect to insertability (being updatable with
   <a class="link" href="insert.html" title="15.2.7 INSERT Statement">
    <code class="literal">
     INSERT
    </code>
   </a>
   statements), an updatable
      view is insertable if it also satisfies these additional
      requirements for the view columns:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      There must be no duplicate view column names.
     </p>
    </li>
    <li class="listitem">
     <p>
      The view must contain all columns in the base table that do
          not have a default value.
     </p>
    </li>
    <li class="listitem">
     <p>
      The view columns must be simple column references. They must
          not be expressions, such as these:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa72536273"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token number">3.14159</span>
col1 <span class="token operator">+</span> <span class="token number">3</span>
<span class="token function">UPPER</span><span class="token punctuation">(</span>col2<span class="token punctuation">)</span>
col3 <span class="token operator">/</span> col4
<span class="token punctuation">(</span><em class="replaceable">subquery</em><span class="token punctuation">)</span></code></pre>
     </div>
    </li>
   </ul>
  </div>
  <p>
   MySQL sets a flag, called the view updatability flag, at
   <a class="link" href="create-view.html" title="15.1.23 CREATE VIEW Statement">
    <code class="literal">
     CREATE VIEW
    </code>
   </a>
   time. The flag is set
      to
   <code class="literal">
    YES
   </code>
   (true) if
   <a class="link" href="update.html" title="15.2.17 UPDATE Statement">
    <code class="literal">
     UPDATE
    </code>
   </a>
   and
   <a class="link" href="delete.html" title="15.2.2 DELETE Statement">
    <code class="literal">
     DELETE
    </code>
   </a>
   (and similar operations) are
      legal for the view. Otherwise, the flag is set to
   <code class="literal">
    NO
   </code>
   (false). The
   <code class="literal">
    IS_UPDATABLE
   </code>
   column in the Information Schema
   <a class="link" href="information-schema-views-table.html" title="28.3.47 The INFORMATION_SCHEMA VIEWS Table">
    <code class="literal">
     VIEWS
    </code>
   </a>
   table displays the status of
      this flag. It means that the server always knows whether a view is
      updatable.
  </p>
  <p>
   If a view is not updatable, statements such
   <a class="link" href="update.html" title="15.2.17 UPDATE Statement">
    <code class="literal">
     UPDATE
    </code>
   </a>
   ,
   <a class="link" href="delete.html" title="15.2.2 DELETE Statement">
    <code class="literal">
     DELETE
    </code>
   </a>
   , and
   <a class="link" href="insert.html" title="15.2.7 INSERT Statement">
    <code class="literal">
     INSERT
    </code>
   </a>
   are illegal and are
      rejected. (Even if a view is updatable, it might not be possible
      to insert into it, as described elsewhere in this section.)
  </p>
  <p>
   The updatability of views may be affected by the value of the
   <a class="link" href="server-system-variables.html#sysvar_updatable_views_with_limit">
    <code class="literal">
     updatable_views_with_limit
    </code>
   </a>
   system
      variable. See
   <a class="xref" href="server-system-variables.html" title="7.1.8 Server System Variables">
    Section 7.1.8, “Server System Variables”
   </a>
   .
  </p>
  <p>
   For the following discussion, suppose that these tables and views
      exist:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa40240634"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t1 <span class="token punctuation">(</span>x <span class="token datatype">INTEGER</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t2 <span class="token punctuation">(</span>c <span class="token datatype">INTEGER</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">CREATE</span> <span class="token keyword">VIEW</span> vmat <span class="token keyword">AS</span> <span class="token keyword">SELECT</span> <span class="token function">SUM</span><span class="token punctuation">(</span>x<span class="token punctuation">)</span> <span class="token keyword">AS</span> s <span class="token keyword">FROM</span> t1<span class="token punctuation">;</span>
<span class="token keyword">CREATE</span> <span class="token keyword">VIEW</span> vup <span class="token keyword">AS</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t2<span class="token punctuation">;</span>
<span class="token keyword">CREATE</span> <span class="token keyword">VIEW</span> vjoin <span class="token keyword">AS</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> vmat <span class="token keyword">JOIN</span> vup <span class="token keyword">ON</span> vmat<span class="token punctuation">.</span>s<span class="token operator">=</span>vup<span class="token punctuation">.</span>c<span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   <a class="link" href="insert.html" title="15.2.7 INSERT Statement">
    <code class="literal">
     INSERT
    </code>
   </a>
   ,
   <a class="link" href="update.html" title="15.2.17 UPDATE Statement">
    <code class="literal">
     UPDATE
    </code>
   </a>
   , and
   <a class="link" href="delete.html" title="15.2.2 DELETE Statement">
    <code class="literal">
     DELETE
    </code>
   </a>
   statements are permitted as
      follows:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="link" href="insert.html" title="15.2.7 INSERT Statement">
       <code class="literal">
        INSERT
       </code>
      </a>
      : The insert table of an
      <a class="link" href="insert.html" title="15.2.7 INSERT Statement">
       <code class="literal">
        INSERT
       </code>
      </a>
      statement may be a view
          reference that is merged. If the view is a join view, all
          components of the view must be updatable (not materialized).
          For a multiple-table updatable view,
      <a class="link" href="insert.html" title="15.2.7 INSERT Statement">
       <code class="literal">
        INSERT
       </code>
      </a>
      can work if it inserts
          into a single table.
     </p>
     <p>
      This statement is invalid because one component of the join
          view is nonupdatable:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa1114332"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> vjoin <span class="token punctuation">(</span>c<span class="token punctuation">)</span> <span class="token keyword">VALUES</span> <span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      This statement is valid; the view contains no materialized
          components:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa93305356"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> vup <span class="token punctuation">(</span>c<span class="token punctuation">)</span> <span class="token keyword">VALUES</span> <span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="update.html" title="15.2.17 UPDATE Statement">
       <code class="literal">
        UPDATE
       </code>
      </a>
      : The table or tables to
          be updated in an
      <a class="link" href="update.html" title="15.2.17 UPDATE Statement">
       <code class="literal">
        UPDATE
       </code>
      </a>
      statement may be view references that are merged. If a view is
          a join view, at least one component of the view must be
          updatable (this differs from
      <a class="link" href="insert.html" title="15.2.7 INSERT Statement">
       <code class="literal">
        INSERT
       </code>
      </a>
      ).
     </p>
     <p>
      In a multiple-table
      <a class="link" href="update.html" title="15.2.17 UPDATE Statement">
       <code class="literal">
        UPDATE
       </code>
      </a>
      statement, the updated table references of the statement must
          be base tables or updatable view references. Nonupdated table
          references may be materialized views or derived tables.
     </p>
     <p>
      This statement is valid; column
      <code class="literal">
       c
      </code>
      is from
          the updatable part of the join view:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa23965905"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">UPDATE</span> vjoin <span class="token keyword">SET</span> c<span class="token operator">=</span>c<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      This statement is invalid; column
      <code class="literal">
       x
      </code>
      is from
          the nonupdatable part:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa51658981"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">UPDATE</span> vjoin <span class="token keyword">SET</span> x<span class="token operator">=</span>x<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      This statement is valid; the updated table reference of the
          multiple-table
      <a class="link" href="update.html" title="15.2.17 UPDATE Statement">
       <code class="literal">
        UPDATE
       </code>
      </a>
      is an
          updatable view (
      <code class="literal">
       vup
      </code>
      ):
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa40383159"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">UPDATE</span> vup <span class="token keyword">JOIN</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> <span class="token function">SUM</span><span class="token punctuation">(</span>x<span class="token punctuation">)</span> <span class="token keyword">AS</span> s <span class="token keyword">FROM</span> t1<span class="token punctuation">)</span> <span class="token keyword">AS</span> dt <span class="token keyword">ON</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token keyword">SET</span> c<span class="token operator">=</span>c<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      This statement is invalid; it tries to update a materialized
          derived table:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa90771092"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">UPDATE</span> vup <span class="token keyword">JOIN</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> <span class="token function">SUM</span><span class="token punctuation">(</span>x<span class="token punctuation">)</span> <span class="token keyword">AS</span> s <span class="token keyword">FROM</span> t1<span class="token punctuation">)</span> <span class="token keyword">AS</span> dt <span class="token keyword">ON</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token keyword">SET</span> s<span class="token operator">=</span>s<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">;</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="delete.html" title="15.2.2 DELETE Statement">
       <code class="literal">
        DELETE
       </code>
      </a>
      : The table or tables to
          be deleted from in a
      <a class="link" href="delete.html" title="15.2.2 DELETE Statement">
       <code class="literal">
        DELETE
       </code>
      </a>
      statement must be merged views. Join views are not allowed
          (this differs from
      <a class="link" href="insert.html" title="15.2.7 INSERT Statement">
       <code class="literal">
        INSERT
       </code>
      </a>
      and
      <a class="link" href="update.html" title="15.2.17 UPDATE Statement">
       <code class="literal">
        UPDATE
       </code>
      </a>
      ).
     </p>
     <p>
      This statement is invalid because the view is a join view:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa76969651"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">DELETE</span> vjoin <span class="token keyword">WHERE</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      This statement is valid because the view is a merged
          (updatable) view:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa30662876"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">DELETE</span> vup <span class="token keyword">WHERE</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      This statement is valid because it deletes from a merged
          (updatable) view:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa71170953"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">DELETE</span> vup <span class="token keyword">FROM</span> vup <span class="token keyword">JOIN</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> <span class="token function">SUM</span><span class="token punctuation">(</span>x<span class="token punctuation">)</span> <span class="token keyword">AS</span> s <span class="token keyword">FROM</span> t1<span class="token punctuation">)</span> <span class="token keyword">AS</span> dt <span class="token keyword">ON</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">;</span></code></pre>
     </div>
    </li>
   </ul>
  </div>
  <p>
   Additional discussion and examples follow.
  </p>
  <p>
   Earlier discussion in this section pointed out that a view is not
      insertable if not all columns are simple column references (for
      example, if it contains columns that are expressions or composite
      expressions). Although such a view is not insertable, it can be
      updatable if you update only columns that are not expressions.
      Consider this view:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa48496003"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">VIEW</span> v <span class="token keyword">AS</span> <span class="token keyword">SELECT</span> col1<span class="token punctuation">,</span> <span class="token number">1</span> <span class="token keyword">AS</span> col2 <span class="token keyword">FROM</span> t<span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   This view is not insertable because
   <code class="literal">
    col2
   </code>
   is an
      expression. But it is updatable if the update does not try to
      update
   <code class="literal">
    col2
   </code>
   . This update is permissible:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa46451590"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">UPDATE</span> v <span class="token keyword">SET</span> col1 <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   This update is not permissible because it attempts to update an
      expression column:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa71790895"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">UPDATE</span> v <span class="token keyword">SET</span> col2 <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   If a table contains an
   <code class="literal">
    AUTO_INCREMENT
   </code>
   column,
      inserting into an insertable view on the table that does not
      include the
   <code class="literal">
    AUTO_INCREMENT
   </code>
   column does not
      change the value of
   <a class="link" href="information-functions.html#function_last-insert-id">
    <code class="literal">
     LAST_INSERT_ID()
    </code>
   </a>
   , because the side
      effects of inserting default values into columns not part of the
      view should not be visible.
  </p>
 </div>
 <br/>
</div>
