<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="atomic-ddl">
      </a>
      15.1.1 Atomic Data Definition Statement Support
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045190236576">
  </a>
  <a class="indexterm" name="idm46045190235568">
  </a>
  <p>
   MySQL 8.4 supports atomic Data Definition Language
      (DDL) statements. This feature is referred to as
   <span class="emphasis">
    <em>
     atomic
      DDL
    </em>
   </span>
   . An atomic DDL statement combines the data
      dictionary updates, storage engine operations, and binary log
      writes associated with a DDL operation into a single, atomic
      operation. The operation is either committed, with applicable
      changes persisted to the data dictionary, storage engine, and
      binary log, or is rolled back, even if the server halts during the
      operation.
  </p>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    <span class="emphasis">
     <em>
      Atomic DDL
     </em>
    </span>
    is not
    <span class="emphasis">
     <em>
      transactional
        DDL
     </em>
    </span>
    . DDL statements, atomic or otherwise, implicitly
        end any transaction that is active in the current session, as if
        you had done a
    <a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
     <code class="literal">
      COMMIT
     </code>
    </a>
    before
        executing the statement. This means that DDL statements cannot
        be performed within another transaction, within transaction
        control statements such as
    <a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
     <code class="literal">
      START TRANSACTION ...
        COMMIT
     </code>
    </a>
    , or combined with other statements within the
        same transaction.
   </p>
  </div>
  <p>
   Atomic DDL is made possible by the MySQL data dictionary, which
      provides centralized, transactional metadata storage.
  </p>
  <p>
   The atomic DDL feature is described under the following topics in
      this section:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="xref" href="atomic-ddl.html#atomic-ddl-supported-statements" title="Supported DDL Statements">
       Supported DDL Statements
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="atomic-ddl.html#atomic-ddl-characteristics" title="Atomic DDL Characteristics">
       Atomic DDL Characteristics
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="atomic-ddl.html#atomic-ddl-statement-behavior" title="DDL Statement Behavior">
       DDL Statement Behavior
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="atomic-ddl.html#atomic-ddl-storage-engine-support" title="Storage Engine Support">
       Storage Engine Support
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="atomic-ddl.html#atomic-ddl-view-logs" title="Viewing DDL Logs">
       Viewing DDL Logs
      </a>
     </p>
    </li>
   </ul>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="atomic-ddl-supported-statements">
       </a>
       Supported DDL Statements
      </h4>
     </div>
    </div>
   </div>
   <p>
    The atomic DDL feature supports both table and non-table DDL
        statements. Table-related DDL operations require storage engine
        support, whereas non-table DDL operations do not. Currently,
        only the
    <code class="literal">
     InnoDB
    </code>
    storage engine supports
        atomic DDL.
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       Supported table DDL statements include
       <code class="literal">
        CREATE
       </code>
       ,
       <code class="literal">
        ALTER
       </code>
       , and
       <code class="literal">
        DROP
       </code>
       statements for databases,
            tablespaces, tables, and indexes, and the
       <a class="link" href="truncate-table.html" title="15.1.37 TRUNCATE TABLE Statement">
        <code class="literal">
         TRUNCATE TABLE
        </code>
       </a>
       statement.
      </p>
     </li>
     <li class="listitem">
      <p>
       Supported non-table DDL statements include:
      </p>
      <div class="itemizedlist">
       <ul class="itemizedlist" style="list-style-type: circle; ">
        <li class="listitem">
         <p>
          <code class="literal">
           CREATE
          </code>
          and
          <code class="literal">
           DROP
          </code>
          statements, and, if applicable,
          <code class="literal">
           ALTER
          </code>
          statements for stored programs, triggers, views, and
                loadable functions.
         </p>
        </li>
        <li class="listitem">
         <p>
          Account management statements:
          <code class="literal">
           CREATE
          </code>
          ,
          <code class="literal">
           ALTER
          </code>
          ,
          <code class="literal">
           DROP
          </code>
          , and, if applicable,
          <code class="literal">
           RENAME
          </code>
          statements for users and
                roles, as well as
          <a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
           <code class="literal">
            GRANT
           </code>
          </a>
          and
          <a class="link" href="revoke.html" title="15.7.1.8 REVOKE Statement">
           <code class="literal">
            REVOKE
           </code>
          </a>
          statements.
         </p>
        </li>
       </ul>
      </div>
     </li>
    </ul>
   </div>
   <p>
    The following statements are not supported by the atomic DDL
        feature:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       Table-related DDL statements that involve a storage engine
            other than
       <code class="literal">
        InnoDB
       </code>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       <a class="link" href="install-plugin.html" title="15.7.4.4 INSTALL PLUGIN Statement">
        <code class="literal">
         INSTALL PLUGIN
        </code>
       </a>
       and
       <a class="link" href="uninstall-plugin.html" title="15.7.4.6 UNINSTALL PLUGIN Statement">
        <code class="literal">
         UNINSTALL PLUGIN
        </code>
       </a>
       statements.
      </p>
     </li>
     <li class="listitem">
      <p>
       <a class="link" href="install-component.html" title="15.7.4.3 INSTALL COMPONENT Statement">
        <code class="literal">
         INSTALL COMPONENT
        </code>
       </a>
       and
       <a class="link" href="uninstall-component.html" title="15.7.4.5 UNINSTALL COMPONENT Statement">
        <code class="literal">
         UNINSTALL COMPONENT
        </code>
       </a>
       statements.
      </p>
     </li>
     <li class="listitem">
      <p>
       <a class="link" href="create-server.html" title="15.1.18 CREATE SERVER Statement">
        <code class="literal">
         CREATE SERVER
        </code>
       </a>
       ,
       <a class="link" href="alter-server.html" title="15.1.8 ALTER SERVER Statement">
        <code class="literal">
         ALTER SERVER
        </code>
       </a>
       , and
       <a class="link" href="drop-server.html" title="15.1.30 DROP SERVER Statement">
        <code class="literal">
         DROP SERVER
        </code>
       </a>
       statements.
      </p>
     </li>
    </ul>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="atomic-ddl-characteristics">
       </a>
       Atomic DDL Characteristics
      </h4>
     </div>
    </div>
   </div>
   <p>
    The characteristics of atomic DDL statements include the
        following:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       Metadata updates, binary log writes, and storage engine
            operations, where applicable, are combined into a single
            atomic operation.
      </p>
     </li>
     <li class="listitem">
      <p>
       There are no intermediate commits at the SQL layer during
            the DDL operation.
      </p>
     </li>
     <li class="listitem">
      <p>
       Where applicable:
      </p>
      <div class="itemizedlist">
       <ul class="itemizedlist" style="list-style-type: circle; ">
        <li class="listitem">
         <p>
          The state of data dictionary, routine, event, and
                loadable function caches is consistent with the status
                of the DDL operation, meaning that caches are updated to
                reflect whether or not the DDL operation was completed
                successfully or rolled back.
         </p>
        </li>
        <li class="listitem">
         <p>
          The storage engine methods involved in a DDL operation
                do not perform intermediate commits, and the storage
                engine registers itself as part of the DDL operation.
         </p>
        </li>
        <li class="listitem">
         <p>
          The storage engine supports redo and rollback of DDL
                operations, which is performed in the
          <span class="emphasis">
           <em>
            Post-DDL
           </em>
          </span>
          phase of the DDL
                operation.
         </p>
        </li>
       </ul>
      </div>
     </li>
     <li class="listitem">
      <p>
       The visible behaviour of DDL operations is atomic.
      </p>
     </li>
    </ul>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="atomic-ddl-statement-behavior">
       </a>
       DDL Statement Behavior
      </h4>
     </div>
    </div>
   </div>
   <p>
    This section describes some important aspects of DDL statement
        behavior when using a storage engine that support atomic DDL,
        such as
    <a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
     <code class="literal">
      InnoDB
     </code>
    </a>
    .
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       <a class="link" href="drop-table.html" title="15.1.32 DROP TABLE Statement">
        <code class="literal">
         DROP TABLE
        </code>
       </a>
       operations are
            fully atomic if all named tables use a storage engine which
            supports atomic DDL. The statement either drops all tables
            successfully or is rolled back.
      </p>
      <p>
       <a class="link" href="drop-table.html" title="15.1.32 DROP TABLE Statement">
        <code class="literal">
         DROP TABLE
        </code>
       </a>
       fails with an
            error if a named table does not exist, and no changes are
            made, regardless of the storage engine.
      </p>
     </li>
     <li class="listitem">
      <p>
       <a class="link" href="drop-database.html" title="15.1.24 DROP DATABASE Statement">
        <code class="literal">
         DROP DATABASE
        </code>
       </a>
       is atomic if
            all tables use a storage engine which supports atomic DDL.
            The statement either drops all objects successfully or is
            rolled back. You should be aware that removal of the
            database directory from the file system occurs last and is
            not part of the atomic operation; thus, if removal of the
            database directory fails due to a file system error or
            server halt, the
       <a class="link" href="drop-database.html" title="15.1.24 DROP DATABASE Statement">
        <code class="literal">
         DROP
            DATABASE
        </code>
       </a>
       transaction is not rolled back.
      </p>
     </li>
     <li class="listitem">
      <p>
       For tables that do not use a storage engine which supports
            atomic DDL, table deletion occurs outside of the atomic
       <a class="link" href="drop-table.html" title="15.1.32 DROP TABLE Statement">
        <code class="literal">
         DROP TABLE
        </code>
       </a>
       or
       <a class="link" href="drop-database.html" title="15.1.24 DROP DATABASE Statement">
        <code class="literal">
         DROP DATABASE
        </code>
       </a>
       transaction.
            Such table deletions are written to the binary log
            individually, which limits the discrepancy between the
            storage engine, data dictionary, and binary log to one table
            at most in the case of an interrupted
       <a class="link" href="drop-table.html" title="15.1.32 DROP TABLE Statement">
        <code class="literal">
         DROP TABLE
        </code>
       </a>
       or
       <a class="link" href="drop-database.html" title="15.1.24 DROP DATABASE Statement">
        <code class="literal">
         DROP DATABASE
        </code>
       </a>
       operation. For
            operations that drop multiple tables, any tables that do not
            use a storage engine which supports atomic DDL are dropped
            before tables that do so.
      </p>
     </li>
     <li class="listitem">
      <p>
       <a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
        <code class="literal">
         CREATE TABLE
        </code>
       </a>
       ,
       <a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
        <code class="literal">
         ALTER TABLE
        </code>
       </a>
       ,
       <a class="link" href="rename-table.html" title="15.1.36 RENAME TABLE Statement">
        <code class="literal">
         RENAME TABLE
        </code>
       </a>
       ,
       <a class="link" href="truncate-table.html" title="15.1.37 TRUNCATE TABLE Statement">
        <code class="literal">
         TRUNCATE TABLE
        </code>
       </a>
       ,
       <a class="link" href="create-tablespace.html" title="15.1.21 CREATE TABLESPACE Statement">
        <code class="literal">
         CREATE TABLESPACE
        </code>
       </a>
       , and
       <a class="link" href="drop-tablespace.html" title="15.1.33 DROP TABLESPACE Statement">
        <code class="literal">
         DROP TABLESPACE
        </code>
       </a>
       operations
            for tables that use a storage engine which supports atomic
            DDL are either fully committed or rolled back if the server
            halts during their operation.
       <a class="link" href="rename-table.html" title="15.1.36 RENAME TABLE Statement">
        <code class="literal">
         RENAME
            TABLE
        </code>
       </a>
       operations are atomic only if all named
            tables use a storage engine which supports atomic DDL.
      </p>
     </li>
     <li class="listitem">
      <p>
       For storage engines that support atomic DDL, 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 is logged as one
            transaction in the binary log when row-based replication is
            in use.
      </p>
      <p>
       On storage engines that support both atomic DDL and foreign
            key constraints, creation of foreign keys is not permitted
            in
       <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 when row-based
            replication is in use. Foreign key constraints can be added
            later using
       <a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
        <code class="literal">
         ALTER TABLE
        </code>
       </a>
       .
      </p>
      <p>
       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>
       is applied as an atomic
            operation, a metadata lock is held on the table while data
            is inserted, which prevents concurrent access to the table
            for the duration of the operation.
      </p>
     </li>
     <li class="listitem">
      <p>
       <a class="link" href="drop-view.html" title="15.1.35 DROP VIEW Statement">
        <code class="literal">
         DROP VIEW
        </code>
       </a>
       fails if a named
            view does not exist, and no changes are made.
      </p>
     </li>
     <li class="listitem">
      <p>
       Account management statements either succeed for all named
            users or roll back and have no effect if an error occurs.
      </p>
     </li>
    </ul>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="atomic-ddl-storage-engine-support">
       </a>
       Storage Engine Support
      </h4>
     </div>
    </div>
   </div>
   <p>
    Currently, only the
    <code class="literal">
     InnoDB
    </code>
    storage engine
        supports atomic DDL. Storage engines that do not support atomic
        DDL are exempted from DDL atomicity. DDL operations involving
        exempted storage engines remain capable of introducing
        inconsistencies that can occur when operations are interrupted
        or only partially completed.
   </p>
   <p>
    To support redo and rollback of DDL operations,
    <code class="literal">
     InnoDB
    </code>
    writes DDL logs to the
    <code class="literal">
     mysql.innodb_ddl_log
    </code>
    table, which is a hidden
        data dictionary table that resides in the
    <code class="filename">
     mysql.ibd
    </code>
    data dictionary tablespace.
   </p>
   <p>
    To view DDL logs that are written to the
    <code class="literal">
     mysql.innodb_ddl_log
    </code>
    table during a DDL
        operation, enable the
    <a class="link" href="innodb-parameters.html#sysvar_innodb_print_ddl_logs">
     <code class="literal">
      innodb_print_ddl_logs
     </code>
    </a>
    configuration option. For more information, see
    <a class="xref" href="atomic-ddl.html#atomic-ddl-view-logs" title="Viewing DDL Logs">
     Viewing DDL Logs
    </a>
    .
   </p>
   <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
    <div class="admon-title">
     Note
    </div>
    <p>
     The redo logs for changes to the
     <code class="literal">
      mysql.innodb_ddl_log
     </code>
     table are flushed to
          disk immediately regardless of the
     <a class="link" href="innodb-parameters.html#sysvar_innodb_flush_log_at_trx_commit">
      <code class="literal">
       innodb_flush_log_at_trx_commit
      </code>
     </a>
     setting. Flushing the redo logs immediately avoids situations
          where data files are modified by DDL operations but the redo
          logs for changes to the
     <code class="literal">
      mysql.innodb_ddl_log
     </code>
     table resulting from
          those operations are not persisted to disk. Such a situation
          could cause errors during rollback or recovery.
    </p>
   </div>
   <p>
    The
    <code class="literal">
     InnoDB
    </code>
    storage engine executes DDL
        operations in phases. DDL operations such as
    <a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
     <code class="literal">
      ALTER TABLE
     </code>
    </a>
    may perform the
    <span class="emphasis">
     <em>
      Prepare
     </em>
    </span>
    and
    <span class="emphasis">
     <em>
      Perform
     </em>
    </span>
    phases multiple times prior to the
    <span class="emphasis">
     <em>
      Commit
     </em>
    </span>
    phase.
   </p>
   <div class="orderedlist">
    <ol class="orderedlist" type="1">
     <li class="listitem">
      <p>
       <span class="emphasis">
        <em>
         Prepare
        </em>
       </span>
       : Create the required objects
            and write the DDL logs to the
       <code class="literal">
        mysql.innodb_ddl_log
       </code>
       table. The DDL logs
            define how to roll forward and roll back the DDL operation.
      </p>
     </li>
     <li class="listitem">
      <p>
       <span class="emphasis">
        <em>
         Perform
        </em>
       </span>
       : Perform the DDL operation. For
            example, perform a create routine for a
       <code class="literal">
        CREATE
            TABLE
       </code>
       operation.
      </p>
     </li>
     <li class="listitem">
      <p>
       <span class="emphasis">
        <em>
         Commit
        </em>
       </span>
       : Update the data dictionary and
            commit the data dictionary transaction.
      </p>
     </li>
     <li class="listitem">
      <p>
       <span class="emphasis">
        <em>
         Post-DDL
        </em>
       </span>
       : Replay and remove DDL logs
            from the
       <code class="literal">
        mysql.innodb_ddl_log
       </code>
       table. To
            ensure that rollback can be performed safely without
            introducing inconsistencies, file operations such as
            renaming or removing data files are performed in this final
            phase. This phase also removes dynamic metadata from the
       <code class="literal">
        mysql.innodb_dynamic_metadata
       </code>
       data
            dictionary table for
       <a class="link" href="drop-table.html" title="15.1.32 DROP TABLE Statement">
        <code class="literal">
         DROP
            TABLE
        </code>
       </a>
       ,
       <a class="link" href="truncate-table.html" title="15.1.37 TRUNCATE TABLE Statement">
        <code class="literal">
         TRUNCATE
            TABLE
        </code>
       </a>
       , and other DDL operations that rebuild the
            table.
      </p>
     </li>
    </ol>
   </div>
   <p>
    DDL logs are replayed and removed from the
    <code class="literal">
     mysql.innodb_ddl_log
    </code>
    table during the
    <span class="emphasis">
     <em>
      Post-DDL
     </em>
    </span>
    phase, regardless of whether the
        DDL operation is committed or rolled back. DDL logs should only
        remain in the
    <code class="literal">
     mysql.innodb_ddl_log
    </code>
    table if
        the server is halted during a DDL operation. In this case, the
        DDL logs are replayed and removed after recovery.
   </p>
   <p>
    In a recovery situation, a DDL operation may be committed or
        rolled back when the server is restarted. If the data dictionary
        transaction that was performed during the
    <span class="emphasis">
     <em>
      Commit
     </em>
    </span>
    phase of a DDL operation is present
        in the redo log and binary log, the operation is considered
        successful and is rolled forward. Otherwise, the incomplete data
        dictionary transaction is rolled back when
    <code class="literal">
     InnoDB
    </code>
    replays data dictionary redo logs, and
        the DDL operation is rolled back.
   </p>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="atomic-ddl-view-logs">
       </a>
       Viewing DDL Logs
      </h4>
     </div>
    </div>
   </div>
   <p>
    To view DDL logs that are written to the
    <code class="literal">
     mysql.innodb_ddl_log
    </code>
    data dictionary table
        during atomic DDL operations that involve the
    <code class="literal">
     InnoDB
    </code>
    storage engine, enable
    <a class="link" href="innodb-parameters.html#sysvar_innodb_print_ddl_logs">
     <code class="literal">
      innodb_print_ddl_logs
     </code>
    </a>
    to have
        MySQL write the DDL logs to
    <code class="literal">
     stderr
    </code>
    . Depending
        on the host operating system and MySQL configuration,
    <code class="literal">
     stderr
    </code>
    may be the error log, terminal, or
        console window. See
    <a class="xref" href="error-log-destination-configuration.html" title="7.4.2.2 Default Error Log Destination Configuration">
     Section 7.4.2.2, “Default Error Log Destination Configuration”
    </a>
    .
   </p>
   <p>
    <code class="literal">
     InnoDB
    </code>
    writes DDL logs to the
    <code class="literal">
     mysql.innodb_ddl_log
    </code>
    table to support redo
        and rollback of DDL operations. The
    <code class="literal">
     mysql.innodb_ddl_log
    </code>
    table is a hidden data
        dictionary table that resides in the
    <code class="filename">
     mysql.ibd
    </code>
    data dictionary tablespace. Like
        other hidden data dictionary tables, the
    <code class="literal">
     mysql.innodb_ddl_log
    </code>
    table cannot be accessed
        directly in non-debug versions of MySQL. (See
    <a class="xref" href="data-dictionary-schema.html" title="16.1 Data Dictionary Schema">
     Section 16.1, “Data Dictionary Schema”
    </a>
    .) The structure of the
    <code class="literal">
     mysql.innodb_ddl_log
    </code>
    table corresponds to
        this definition:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa7110342"><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> mysql<span class="token punctuation">.</span>innodb_ddl_log <span class="token punctuation">(</span>
  id <span class="token datatype">BIGINT</span> <span class="token keyword">UNSIGNED</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span> <span class="token keyword">AUTO_INCREMENT</span> <span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span><span class="token punctuation">,</span>
  thread_id <span class="token datatype">BIGINT</span> <span class="token keyword">UNSIGNED</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
  <span class="token keyword">type</span> <span class="token datatype">INT</span> <span class="token keyword">UNSIGNED</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
  space_id <span class="token datatype">INT</span> <span class="token keyword">UNSIGNED</span><span class="token punctuation">,</span>
  page_no <span class="token datatype">INT</span> <span class="token keyword">UNSIGNED</span><span class="token punctuation">,</span>
  index_id <span class="token datatype">BIGINT</span> <span class="token keyword">UNSIGNED</span><span class="token punctuation">,</span>
  table_id <span class="token datatype">BIGINT</span> <span class="token keyword">UNSIGNED</span><span class="token punctuation">,</span>
  old_file_path <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">512</span><span class="token punctuation">)</span> <span class="token keyword">COLLATE</span> utf8mb4_bin<span class="token punctuation">,</span>
  new_file_path <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">512</span><span class="token punctuation">)</span> <span class="token keyword">COLLATE</span> utf8mb4_bin<span class="token punctuation">,</span>
  <span class="token keyword">KEY</span><span class="token punctuation">(</span>thread_id<span class="token punctuation">)</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
   </div>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       <code class="literal">
        id
       </code>
       : A unique identifier for a DDL log
            record.
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        thread_id
       </code>
       : Each DDL log record is
            assigned a
       <code class="literal">
        thread_id
       </code>
       , which is used to
            replay and remove DDL logs that belong to a particular DDL
            operation. DDL operations that involve multiple data file
            operations generate multiple DDL log records.
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        type
       </code>
       : The DDL operation type. Types
            include
       <code class="literal">
        FREE
       </code>
       (drop an index tree),
       <code class="literal">
        DELETE
       </code>
       (delete a file),
       <code class="literal">
        RENAME
       </code>
       (rename a file), or
       <code class="literal">
        DROP
       </code>
       (drop metadata from the
       <code class="literal">
        mysql.innodb_dynamic_metadata
       </code>
       data
            dictionary table).
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        space_id
       </code>
       : The tablespace ID.
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        page_no
       </code>
       : A page that contains allocation
            information; an index tree root page, for example.
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        index_id
       </code>
       : The index ID.
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        table_id
       </code>
       : The table ID.
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        old_file_path
       </code>
       : The old tablespace file
            path. Used by DDL operations that create or drop tablespace
            files; also used by DDL operations that rename a tablespace.
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        new_file_path
       </code>
       : The new tablespace file
            path. Used by DDL operations that rename tablespace files.
      </p>
     </li>
    </ul>
   </div>
   <p>
    This example demonstrates enabling
    <a class="link" href="innodb-parameters.html#sysvar_innodb_print_ddl_logs">
     <code class="literal">
      innodb_print_ddl_logs
     </code>
    </a>
    to view
        DDL logs written to
    <code class="literal">
     strderr
    </code>
    for a
    <code class="literal">
     CREATE TABLE
    </code>
    operation.
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa57656982"><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 prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token keyword">GLOBAL</span> innodb_print_ddl_logs<span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">;</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t1 <span class="token punctuation">(</span>c1 <span class="token datatype">INT</span><span class="token punctuation">)</span> <span class="token keyword">ENGINE</span> <span class="token operator">=</span> InnoDB<span class="token punctuation">;</span></code></pre>
   </div>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-none"><div class="docs-select-all right" id="sa99939615"><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-none">[Note] [000000] InnoDB: DDL log insert : [DDL record: DELETE SPACE, id=18, thread_id=7,
space_id=5, old_file_path=./test/t1.ibd]
[Note] [000000] InnoDB: DDL log delete : by id 18
[Note] [000000] InnoDB: DDL log insert : [DDL record: REMOVE CACHE, id=19, thread_id=7,
table_id=1058, new_file_path=test/t1]
[Note] [000000] InnoDB: DDL log delete : by id 19
[Note] [000000] InnoDB: DDL log insert : [DDL record: FREE, id=20, thread_id=7,
space_id=5, index_id=132, page_no=4]
[Note] [000000] InnoDB: DDL log delete : by id 20
[Note] [000000] InnoDB: DDL log post ddl : begin for thread id : 7
[Note] [000000] InnoDB: DDL log post ddl : end for thread id : 7</code></pre>
   </div>
  </div>
 </div>
 <br/>
</div>
