<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="mysql-cluster-online-operations">
      </a>
      25.6.12 Online Operations with ALTER TABLE in NDB Cluster
     </h3>
    </div>
   </div>
  </div>
  <p>
   MySQL NDB Cluster supports online table schema changes using
   <a class="link" href="alter-table.html#alter-table-performance" title="Performance and Space Requirements">
    <code class="literal">
     ALTER
      TABLE ... ALGORITHM=DEFAULT|INPLACE|COPY
    </code>
   </a>
   . NDB Cluster
      handles
   <code class="literal">
    COPY
   </code>
   and
   <code class="literal">
    INPLACE
   </code>
   as
      described in the next few paragraphs.
  </p>
  <p>
   For
   <code class="literal">
    ALGORITHM=COPY
   </code>
   , the
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   NDB Cluster handler performs the
      following actions:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Tells the data nodes to create an empty copy of the table, and
          to make the required schema changes to this copy.
     </p>
    </li>
    <li class="listitem">
     <p>
      Reads rows from the original table, and writes them to the
          copy.
     </p>
    </li>
    <li class="listitem">
     <p>
      Tells the data nodes to drop the original table and then to
          rename the copy.
     </p>
    </li>
   </ul>
  </div>
  <p>
   We sometimes refer to this as a
   <span class="quote">
    “
    <span class="quote">
     copying
    </span>
    ”
   </span>
   or
   <span class="quote">
    “
    <span class="quote">
     offline
    </span>
    ”
   </span>
   <code class="literal">
    ALTER TABLE
   </code>
   .
  </p>
  <p>
   DML operations are not permitted concurrently with a copying
   <code class="literal">
    ALTER TABLE
   </code>
   .
  </p>
  <p>
   The
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   on which the copying
   <code class="literal">
    ALTER
      TABLE
   </code>
   statement is issued takes a metadata lock, but
      this is in effect only on that
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   . Other
   <code class="literal">
    NDB
   </code>
   clients can modify row data during a
      copying
   <code class="literal">
    ALTER TABLE
   </code>
   , resulting in
      inconsistency.
  </p>
  <p>
   For
   <code class="literal">
    ALGORITHM=INPLACE
   </code>
   , the NDB Cluster handler
      tells the data nodes to make the required changes, and does not
      perform any copying of data.
  </p>
  <p>
   We also refer to this as a
   <span class="quote">
    “
    <span class="quote">
     non-copying
    </span>
    ”
   </span>
   or
   <span class="quote">
    “
    <span class="quote">
     online
    </span>
    ”
   </span>
   <code class="literal">
    ALTER TABLE
   </code>
   .
  </p>
  <p>
   A non-copying
   <code class="literal">
    ALTER TABLE
   </code>
   allows concurrent DML
      operations.
  </p>
  <p>
   <code class="literal">
    ALGORITHM=INSTANT
   </code>
   is not supported by NDB
      8.4.
  </p>
  <p>
   Regardless of the algorithm used, the
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   takes a Global Schema Lock (GSL) while executing
   <span class="command">
    <strong>
     ALTER
      TABLE
    </strong>
   </span>
   ; this prevents execution of any (other) DDL or
      backups concurrently on this or any other SQL node in the cluster.
      This is normally not problematic, unless the
   <code class="literal">
    ALTER
      TABLE
   </code>
   takes a very long time.
  </p>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    Some older releases of NDB Cluster used a syntax specific to
    <a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
     <code class="literal">
      NDB
     </code>
    </a>
    for online
    <code class="literal">
     ALTER
        TABLE
    </code>
    operations. That syntax has since been removed.
   </p>
  </div>
  <p>
   Operations that add and drop indexes on variable-width columns of
   <a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
    <code class="literal">
     NDB
    </code>
   </a>
   tables occur online. Online
      operations are noncopying; that is, they do not require that
      indexes be re-created. They do not lock the table being altered
      from access by other API nodes in an NDB Cluster (but see
   <a class="xref" href="mysql-cluster-online-operations.html#mysql-cluster-online-limitations" title="Limitations of NDB online operations">
    Limitations of NDB online operations
   </a>
   , later in this
      section). Such operations do not require single user mode for
   <a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
    <code class="literal">
     NDB
    </code>
   </a>
   table alterations made in an NDB
      cluster with multiple API nodes; transactions can continue
      uninterrupted during online DDL operations.
  </p>
  <p>
   <code class="literal">
    ALGORITHM=INPLACE
   </code>
   can be used to perform online
   <code class="literal">
    ADD COLUMN
   </code>
   ,
   <code class="literal">
    ADD INDEX
   </code>
   (including
   <code class="literal">
    CREATE INDEX
   </code>
   statements), and
   <code class="literal">
    DROP INDEX
   </code>
   operations on
   <a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
    <code class="literal">
     NDB
    </code>
   </a>
   tables. Online renaming of
   <a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
    <code class="literal">
     NDB
    </code>
   </a>
   tables is also supported.
  </p>
  <p>
   Disk-based columns cannot be added to
   <a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
    <code class="literal">
     NDB
    </code>
   </a>
   tables online. This means that,
      if you wish to add an in-memory column to an
   <a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
    <code class="literal">
     NDB
    </code>
   </a>
   table that uses a table-level
   <code class="literal">
    STORAGE DISK
   </code>
   option, you must declare the new
      column as using memory-based storage explicitly. For
      example—assuming that you have already created tablespace
   <code class="literal">
    ts1
   </code>
   —suppose that you create table
   <code class="literal">
    t1
   </code>
   as follows:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa39953081"><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">CREATE</span> <span class="token keyword">TABLE</span> t1 <span class="token punctuation">(</span>
     <span class="token operator">&gt;</span>     c1 <span class="token datatype">INT</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span> <span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span><span class="token punctuation">,</span>
     <span class="token operator">&gt;</span>     c2 <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">30</span><span class="token punctuation">)</span>
     <span class="token operator">&gt;</span>     <span class="token punctuation">)</span>
     <span class="token operator">&gt;</span>     <span class="token keyword">TABLESPACE</span> ts1 <span class="token keyword">STORAGE</span> <span class="token keyword">DISK</span>
     <span class="token operator">&gt;</span>     <span class="token keyword">ENGINE</span> <span class="token keyword">NDB</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (1.73 sec)</span>
<span class="token output">Records: 0  Duplicates: 0  Warnings: 0</span></code></pre>
  </div>
  <p>
   You can add a new in-memory column to this table online as shown
      here:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa74169948"><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">ALTER</span> <span class="token keyword">TABLE</span> t1
     <span class="token operator">&gt;</span>     <span class="token keyword">ADD</span> <span class="token keyword">COLUMN</span> c3 <span class="token datatype">INT</span> <span class="token keyword">COLUMN_FORMAT</span> <span class="token keyword">DYNAMIC</span> <span class="token keyword">STORAGE</span> <span class="token keyword">MEMORY</span><span class="token punctuation">,</span>
     <span class="token operator">&gt;</span>     <span class="token keyword">ALGORITHM</span><span class="token operator">=</span><span class="token keyword">INPLACE</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (1.25 sec)</span>
<span class="token output">Records: 0  Duplicates: 0  Warnings: 0</span></code></pre>
  </div>
  <p>
   This statement fails if the
   <code class="literal">
    STORAGE MEMORY
   </code>
   option is omitted:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa83381785"><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">ALTER</span> <span class="token keyword">TABLE</span> t1
     <span class="token operator">&gt;</span>     <span class="token keyword">ADD</span> <span class="token keyword">COLUMN</span> c4 <span class="token datatype">INT</span> <span class="token keyword">COLUMN_FORMAT</span> <span class="token keyword">DYNAMIC</span><span class="token punctuation">,</span>
     <span class="token operator">&gt;</span>     <span class="token keyword">ALGORITHM</span><span class="token operator">=</span><span class="token keyword">INPLACE</span><span class="token punctuation">;</span>
<span class="token output">ERROR 1846 (0A000)<span class="token punctuation">:</span> ALGORITHM=INPLACE is not supported. Reason<span class="token punctuation">:</span>
Adding column(s) or add/reorganize partition not supported online. Try
ALGORITHM=COPY.</span></code></pre>
  </div>
  <p>
   If you omit the
   <code class="literal">
    COLUMN_FORMAT DYNAMIC
   </code>
   option,
      the dynamic column format is employed automatically, but a warning
      is issued, as shown here:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa28085521"><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">ALTER</span> ONLINE <span class="token keyword">TABLE</span> t1 <span class="token keyword">ADD</span> <span class="token keyword">COLUMN</span> c4 <span class="token datatype">INT</span> <span class="token keyword">STORAGE</span> <span class="token keyword">MEMORY</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected, 1 warning (1.17 sec)</span>
<span class="token output">Records: 0  Duplicates: 0  Warnings: 0</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SHOW</span> <span class="token keyword">WARNINGS</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
  Level<span class="token punctuation">:</span> Warning
   Code<span class="token punctuation">:</span> 1478
Message<span class="token punctuation">:</span> DYNAMIC column c4 with STORAGE DISK is not supported, column will
become FIXED

</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SHOW</span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t1\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
       Table<span class="token punctuation">:</span> t1
Create Table<span class="token punctuation">:</span> CREATE TABLE `t1` (
  `c1` int(11) NOT NULL,
  `c2` varchar(30) DEFAULT NULL,
  `c3` int(11) /<span class="token punctuation">*</span>!50606 STORAGE MEMORY <span class="token punctuation">*</span>/ /<span class="token punctuation">*</span>!50606 COLUMN_FORMAT DYNAMIC <span class="token punctuation">*</span>/ DEFAULT NULL,
  `c4` int(11) /<span class="token punctuation">*</span>!50606 STORAGE MEMORY <span class="token punctuation">*</span>/ DEFAULT NULL,
  PRIMARY KEY (`c1`)
) /<span class="token punctuation">*</span>!50606 TABLESPACE ts_1 STORAGE DISK <span class="token punctuation">*</span>/ ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
</span><span class="token output">1 row in set (0.03 sec)</span></code></pre>
  </div>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    The
    <code class="literal">
     STORAGE
    </code>
    and
    <code class="literal">
     COLUMN_FORMAT
    </code>
    keywords are supported only in
        NDB Cluster; in any other version of MySQL, attempting to use
        either of these keywords in a
    <a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
     <code class="literal">
      CREATE
        TABLE
     </code>
    </a>
    or
    <a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
     <code class="literal">
      ALTER TABLE
     </code>
    </a>
    statement results in an error.
   </p>
  </div>
  <p>
   It is also possible to use the statement
   <code class="literal">
    ALTER TABLE ...
      REORGANIZE PARTITION, ALGORITHM=INPLACE
   </code>
   with no
   <code class="literal">
    <em class="replaceable">
     <code>
      partition_names
     </code>
    </em>
    INTO
      (
    <em class="replaceable">
     <code>
      partition_definitions
     </code>
    </em>
    )
   </code>
   option on
   <a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
    <code class="literal">
     NDB
    </code>
   </a>
   tables. This can be
      used to redistribute NDB Cluster data among new data nodes that
      have been added to the cluster online. This does
   <span class="emphasis">
    <em>
     not
    </em>
   </span>
   perform any defragmentation, which
      requires an
   <a class="link" href="optimize-table.html" title="15.7.3.4 OPTIMIZE TABLE Statement">
    <code class="literal">
     OPTIMIZE TABLE
    </code>
   </a>
   or null
   <a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
    <code class="literal">
     ALTER TABLE
    </code>
   </a>
   statement. For more
      information, see
   <a class="xref" href="mysql-cluster-online-add-node.html" title="25.6.7 Adding NDB Cluster Data Nodes Online">
    Section 25.6.7, “Adding NDB Cluster Data Nodes Online”
   </a>
   .
  </p>
  <h4>
   <a name="mysql-cluster-online-limitations">
   </a>
   Limitations of NDB online operations
  </h4>
  <p>
   Online
   <code class="literal">
    DROP COLUMN
   </code>
   operations are not
      supported.
  </p>
  <p>
   Online
   <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="create-index.html" title="15.1.15 CREATE INDEX Statement">
    <code class="literal">
     CREATE INDEX
    </code>
   </a>
   , or
   <a class="link" href="drop-index.html" title="15.1.27 DROP INDEX Statement">
    <code class="literal">
     DROP INDEX
    </code>
   </a>
   statements that add
      columns or add or drop indexes are subject to the following
      limitations:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      A given online
      <a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
       <code class="literal">
        ALTER TABLE
       </code>
      </a>
      can
          use only one of
      <code class="literal">
       ADD COLUMN
      </code>
      ,
      <code class="literal">
       ADD
          INDEX
      </code>
      , or
      <code class="literal">
       DROP INDEX
      </code>
      . One or more
          columns can be added online in a single statement; only one
          index may be created or dropped online in a single statement.
     </p>
    </li>
    <li class="listitem">
     <p>
      The table being altered is not locked with respect to API
          nodes other than the one on which an online
      <a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
       <code class="literal">
        ALTER TABLE
       </code>
      </a>
      <code class="literal">
       ADD
          COLUMN
      </code>
      ,
      <code class="literal">
       ADD INDEX
      </code>
      , or
      <code class="literal">
       DROP INDEX
      </code>
      operation (or
      <a class="link" href="create-index.html" title="15.1.15 CREATE INDEX Statement">
       <code class="literal">
        CREATE INDEX
       </code>
      </a>
      or
      <a class="link" href="drop-index.html" title="15.1.27 DROP INDEX Statement">
       <code class="literal">
        DROP INDEX
       </code>
      </a>
      statement) is run.
          However, the table is locked against any other operations
          originating on the
      <span class="emphasis">
       <em>
        same
       </em>
      </span>
      API node while
          the online operation is being executed.
     </p>
    </li>
    <li class="listitem">
     <p>
      The table to be altered must have an explicit primary key; the
          hidden primary key created by the
      <a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
       <code class="literal">
        NDB
       </code>
      </a>
      storage engine is not
          sufficient for this purpose.
     </p>
    </li>
    <li class="listitem">
     <p>
      The storage engine used by the table cannot be changed online.
     </p>
    </li>
    <li class="listitem">
     <p>
      The tablespace used by the table cannot be changed online.
          Statements such as
      <a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
       <code class="literal">
        ALTER TABLE
        <em class="replaceable">
         <code>
          ndb_table
         </code>
        </em>
        ... ALGORITHM=INPLACE,
          TABLESPACE=
        <em class="replaceable">
         <code>
          new_tablespace
         </code>
        </em>
       </code>
      </a>
      are specifically disallowed.
     </p>
    </li>
    <li class="listitem">
     <p>
      When used with NDB Cluster Disk Data tables, it is not
          possible to change the storage type (
      <code class="literal">
       DISK
      </code>
      or
      <code class="literal">
       MEMORY
      </code>
      ) of a column online. This means,
          that when you add or drop an index in such a way that the
          operation would be performed online, and you want the storage
          type of the column or columns to be changed, you must use
      <code class="literal">
       ALGORITHM=COPY
      </code>
      in the statement that adds
          or drops the index.
     </p>
    </li>
   </ul>
  </div>
  <p>
   Columns to be added online cannot use the
   <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
    <code class="literal">
     BLOB
    </code>
   </a>
   or
   <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
    <code class="literal">
     TEXT
    </code>
   </a>
   type, and must meet the
      following criteria:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      The columns must be dynamic; that is, it must be possible to
          create them using
      <code class="literal">
       COLUMN_FORMAT DYNAMIC
      </code>
      . If
          you omit the
      <code class="literal">
       COLUMN_FORMAT DYNAMIC
      </code>
      option,
          the dynamic column format is employed automatically.
     </p>
    </li>
    <li class="listitem">
     <p>
      The columns must permit
      <code class="literal">
       NULL
      </code>
      values and not
          have any explicit default value other than
      <code class="literal">
       NULL
      </code>
      . Columns added online are
          automatically created as
      <code class="literal">
       DEFAULT NULL
      </code>
      , as
          can be seen here:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa79710977"><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">CREATE</span> <span class="token keyword">TABLE</span> t2 <span class="token punctuation">(</span>
     <span class="token operator">&gt;</span>     c1 <span class="token datatype">INT</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 operator">&gt;</span>     <span class="token punctuation">)</span> <span class="token keyword">ENGINE</span><span class="token operator">=</span><span class="token keyword">NDB</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (1.44 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">ALTER</span> <span class="token keyword">TABLE</span> t2
     <span class="token operator">&gt;</span>     <span class="token keyword">ADD</span> <span class="token keyword">COLUMN</span> c2 <span class="token datatype">INT</span><span class="token punctuation">,</span>
     <span class="token operator">&gt;</span>     <span class="token keyword">ADD</span> <span class="token keyword">COLUMN</span> c3 <span class="token datatype">INT</span><span class="token punctuation">,</span>
     <span class="token operator">&gt;</span>     <span class="token keyword">ALGORITHM</span><span class="token operator">=</span><span class="token keyword">INPLACE</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected, 2 warnings (0.93 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SHOW</span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t1\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
       Table<span class="token punctuation">:</span> t1
Create Table<span class="token punctuation">:</span> CREATE TABLE `t2` (
  `c1` int(11) NOT NULL AUTO_INCREMENT,
  `c2` int(11) DEFAULT NULL,
  `c3` int(11) DEFAULT NULL,
  PRIMARY KEY (`c1`)
) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
</span><span class="token output">1 row in set (0.00 sec)</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      The columns must be added following any existing columns. If
          you attempt to add a column online before any existing columns
          or using the
      <code class="literal">
       FIRST
      </code>
      keyword, the statement
          fails with an error.
     </p>
    </li>
    <li class="listitem">
     <p>
      Existing table columns cannot be reordered online.
     </p>
    </li>
   </ul>
  </div>
  <p>
   For online
   <a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
    <code class="literal">
     ALTER TABLE
    </code>
   </a>
   operations
      on
   <a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
    <code class="literal">
     NDB
    </code>
   </a>
   tables, fixed-format columns
      are converted to dynamic when they are added online, or when
      indexes are created or dropped online, as shown here (repeating
      the
   <code class="literal">
    CREATE TABLE
   </code>
   and
   <code class="literal">
    ALTER
      TABLE
   </code>
   statements just shown for the sake of clarity):
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa36053430"><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">CREATE</span> <span class="token keyword">TABLE</span> t2 <span class="token punctuation">(</span>
     <span class="token operator">&gt;</span>     c1 <span class="token datatype">INT</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 operator">&gt;</span>     <span class="token punctuation">)</span> <span class="token keyword">ENGINE</span><span class="token operator">=</span><span class="token keyword">NDB</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (1.44 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">ALTER</span> <span class="token keyword">TABLE</span> t2
     <span class="token operator">&gt;</span>     <span class="token keyword">ADD</span> <span class="token keyword">COLUMN</span> c2 <span class="token datatype">INT</span><span class="token punctuation">,</span>
     <span class="token operator">&gt;</span>     <span class="token keyword">ADD</span> <span class="token keyword">COLUMN</span> c3 <span class="token datatype">INT</span><span class="token punctuation">,</span>
     <span class="token operator">&gt;</span>     <span class="token keyword">ALGORITHM</span><span class="token operator">=</span><span class="token keyword">INPLACE</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected, 2 warnings (0.93 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SHOW</span> <span class="token keyword">WARNINGS</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
  Level<span class="token punctuation">:</span> Warning
   Code<span class="token punctuation">:</span> 1478
Message<span class="token punctuation">:</span> Converted FIXED field 'c2' to DYNAMIC to enable online ADD COLUMN
<span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 2. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
  Level<span class="token punctuation">:</span> Warning
   Code<span class="token punctuation">:</span> 1478
Message<span class="token punctuation">:</span> Converted FIXED field 'c3' to DYNAMIC to enable online ADD COLUMN
</span><span class="token output">2 rows in set (0.00 sec)</span></code></pre>
  </div>
  <p>
   Only the column or columns to be added online must be dynamic.
      Existing columns need not be; this includes the table's
      primary key, which may also be
   <code class="literal">
    FIXED
   </code>
   , as shown
      here:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa93538708"><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">CREATE</span> <span class="token keyword">TABLE</span> t3 <span class="token punctuation">(</span>
     <span class="token operator">&gt;</span>     c1 <span class="token datatype">INT</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 keyword">COLUMN_FORMAT</span> <span class="token keyword">FIXED</span>
     <span class="token operator">&gt;</span>     <span class="token punctuation">)</span> <span class="token keyword">ENGINE</span><span class="token operator">=</span><span class="token keyword">NDB</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (2.10 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">ALTER</span> <span class="token keyword">TABLE</span> t3 <span class="token keyword">ADD</span> <span class="token keyword">COLUMN</span> c2 <span class="token datatype">INT</span><span class="token punctuation">,</span> <span class="token keyword">ALGORITHM</span><span class="token operator">=</span><span class="token keyword">INPLACE</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected, 1 warning (0.78 sec)</span>
<span class="token output">Records: 0  Duplicates: 0  Warnings: 0</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SHOW</span> <span class="token keyword">WARNINGS</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
  Level<span class="token punctuation">:</span> Warning
   Code<span class="token punctuation">:</span> 1478
Message<span class="token punctuation">:</span> Converted FIXED field 'c2' to DYNAMIC to enable online ADD COLUMN
</span><span class="token output">1 row in set (0.00 sec)</span></code></pre>
  </div>
  <p>
   Columns are not converted from
   <code class="literal">
    FIXED
   </code>
   to
   <code class="literal">
    DYNAMIC
   </code>
   column format by renaming operations.
      For more information about
   <code class="literal">
    COLUMN_FORMAT
   </code>
   , see
   <a class="xref" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
    Section 15.1.20, “CREATE TABLE Statement”
   </a>
   .
  </p>
  <p>
   The
   <code class="literal">
    KEY
   </code>
   ,
   <code class="literal">
    CONSTRAINT
   </code>
   , and
   <code class="literal">
    IGNORE
   </code>
   keywords are supported in
   <a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
    <code class="literal">
     ALTER TABLE
    </code>
   </a>
   statements using
   <code class="literal">
    ALGORITHM=INPLACE
   </code>
   .
  </p>
  <p>
   Setting
   <code class="literal">
    MAX_ROWS
   </code>
   to 0 using an online
   <code class="literal">
    ALTER TABLE
   </code>
   statement is disallowed. You must
      use a copying
   <code class="literal">
    ALTER TABLE
   </code>
   to perform this
      operation. (Bug #21960004)
  </p>
 </div>
 <br/>
</div>
