<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="replication-features-create-select">
      </a>
      19.5.1.7 Replication of CREATE TABLE ... SELECT Statements
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045135901088">
  </a>
  <a class="indexterm" name="idm46045135899632">
  </a>
  <p>
   MySQL applies these rules when
   <a class="link" href="create-table-select.html" title="15.1.20.4 CREATE TABLE ... SELECT Statement">
    <code class="literal">
     CREATE
        TABLE ... SELECT
    </code>
   </a>
   statements are replicated:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="link" href="create-table-select.html" title="15.1.20.4 CREATE TABLE ... SELECT Statement">
       <code class="literal">
        CREATE
            TABLE ... SELECT
       </code>
      </a>
      always performs an implicit
            commit (
      <a class="xref" href="implicit-commit.html" title="15.3.3 Statements That Cause an Implicit Commit">
       Section 15.3.3, “Statements That Cause an Implicit Commit”
      </a>
      ).
     </p>
    </li>
    <li class="listitem">
     <p>
      If the destination table does not exist, logging occurs as
            follows. It does not matter whether
      <code class="literal">
       IF NOT
            EXISTS
      </code>
      is present.
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         <code class="literal">
          STATEMENT
         </code>
         or
         <code class="literal">
          MIXED
         </code>
         format: The statement is logged as written.
        </p>
       </li>
       <li class="listitem">
        <p>
         <code class="literal">
          ROW
         </code>
         format: The statement is logged
                as a
         <a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
          <code class="literal">
           CREATE TABLE
          </code>
         </a>
         statement followed by a series of insert-row events.
        </p>
        <p>
         With storage engines that support atomic DDL, the
                statement is logged as one transaction. For more
                information, see
         <a class="xref" href="atomic-ddl.html" title="15.1.1 Atomic Data Definition Statement Support">
          Section 15.1.1, “Atomic Data Definition Statement Support”
         </a>
         .
        </p>
       </li>
      </ul>
     </div>
    </li>
    <li class="listitem">
     <p>
      If the
      <a class="link" href="create-table-select.html" title="15.1.20.4 CREATE TABLE ... SELECT Statement">
       <code class="literal">
        CREATE
            TABLE ... SELECT
       </code>
      </a>
      statement fails, nothing is
            logged. This includes the case that the destination table
            exists and
      <code class="literal">
       IF NOT EXISTS
      </code>
      is not given.
     </p>
    </li>
    <li class="listitem">
     <p>
      If the destination table exists and
      <code class="literal">
       IF NOT
            EXISTS
      </code>
      is given, MySQL 8.4 ignores
            the statement completely; nothing is inserted or logged.
     </p>
    </li>
   </ul>
  </div>
  <p>
   MySQL 8.4 does not allow a
   <a class="link" href="create-table-select.html" title="15.1.20.4 CREATE TABLE ... SELECT Statement">
    <code class="literal">
     CREATE
        TABLE ... SELECT
    </code>
   </a>
   statement to make any changes in
        tables other than the table that is created by the statement.
  </p>
 </div>
 <br/>
</div>
