<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="constraint-primary-key">
      </a>
      1.7.3.1 PRIMARY KEY and UNIQUE Index Constraints
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045333149440">
  </a>
  <a class="indexterm" name="idm46045333147984">
  </a>
  <a class="indexterm" name="idm46045333146496">
  </a>
  <p>
   Normally, errors occur for data-change statements (such as
   <a class="link" href="insert.html" title="15.2.7 INSERT Statement">
    <code class="literal">
     INSERT
    </code>
   </a>
   or
   <a class="link" href="update.html" title="15.2.17 UPDATE Statement">
    <code class="literal">
     UPDATE
    </code>
   </a>
   ) that would violate
          primary-key, unique-key, or foreign-key constraints. If you
          are using a transactional storage engine such as
   <code class="literal">
    InnoDB
   </code>
   , MySQL automatically rolls back the
          statement. If you are using a nontransactional storage engine,
          MySQL stops processing the statement at the row for which the
          error occurred and leaves any remaining rows unprocessed.
  </p>
  <p>
   MySQL supports an
   <code class="literal">
    IGNORE
   </code>
   keyword for
   <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 so forth. If you
          use it, MySQL ignores primary-key or unique-key violations and
          continues processing with the next row. See the section for
          the statement that you are using (
   <a class="xref" href="insert.html" title="15.2.7 INSERT Statement">
    Section 15.2.7, “INSERT Statement”
   </a>
   ,
   <a class="xref" href="update.html" title="15.2.17 UPDATE Statement">
    Section 15.2.17, “UPDATE Statement”
   </a>
   , and so forth).
  </p>
  <p>
   You can get information about the number of rows actually
          inserted or updated with the
   <a class="ulink" href="/doc/c-api/8.4/en/mysql-info.html" target="_top">
    <code class="literal">
     mysql_info()
    </code>
   </a>
   C API function.
          You can also use the
   <a class="link" href="show-warnings.html" title="15.7.7.42 SHOW WARNINGS Statement">
    <code class="literal">
     SHOW
          WARNINGS
    </code>
   </a>
   statement. See
   <a class="ulink" href="/doc/c-api/8.4/en/mysql-info.html" target="_top">
    mysql_info()
   </a>
   , and
   <a class="xref" href="show-warnings.html" title="15.7.7.42 SHOW WARNINGS Statement">
    Section 15.7.7.42, “SHOW WARNINGS Statement”
   </a>
   .
  </p>
  <p>
   <code class="literal">
    InnoDB
   </code>
   and
   <code class="literal">
    NDB
   </code>
   tables
          support foreign keys. See
   <a class="xref" href="constraint-foreign-key.html" title="1.7.3.2 FOREIGN KEY Constraints">
    Section 1.7.3.2, “FOREIGN KEY Constraints”
   </a>
   .
  </p>
 </div>
 <br/>
</div>
