<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="create-tablespace">
      </a>
      15.1.21 CREATE TABLESPACE Statement
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045184130736">
  </a>
  <a class="indexterm" name="idm46045184129696">
  </a>
  <a class="indexterm" name="idm46045184128208">
  </a>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa69936528"><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 punctuation">[</span><span class="token keyword">UNDO</span><span class="token punctuation">]</span> <span class="token keyword">TABLESPACE</span> <em class="replaceable">tablespace_name</em>

  <em>InnoDB <span class="token operator">and</span> <span class="token keyword">NDB</span>:</em>
    <span class="token punctuation">[</span><span class="token keyword">ADD</span> <span class="token keyword">DATAFILE</span> <span class="token string">'<em class="replaceable">file_name</em>'</span><span class="token punctuation">]</span>
    <span class="token punctuation">[</span><span class="token keyword">AUTOEXTEND_SIZE</span> <span class="token punctuation">[</span><span class="token operator">=</span><span class="token punctuation">]</span> <span class="token keyword"><em class="replaceable">value</em></span><span class="token punctuation">]</span>

  <em>InnoDB <span class="token keyword">only</span>:</em>
    <span class="token punctuation">[</span><span class="token keyword">FILE_BLOCK_SIZE</span> <span class="token operator">=</span> <span class="token keyword">value</span><span class="token punctuation">]</span>
    <span class="token punctuation">[</span><span class="token keyword">ENCRYPTION</span> <span class="token punctuation">[</span><span class="token operator">=</span><span class="token punctuation">]</span> {<span class="token string">'Y'</span> <span class="token operator">|</span> <span class="token string">'N'</span>}<span class="token punctuation">]</span>

  <span class="token keyword"></span><em><span class="token keyword">NDB</span> <span class="token keyword">only</span>:</em>
    <span class="token keyword">USE</span> <span class="token keyword">LOGFILE</span> <span class="token keyword">GROUP</span> <em class="replaceable">logfile_group</em>
    <span class="token punctuation">[</span><span class="token keyword">EXTENT_SIZE</span> <span class="token punctuation">[</span><span class="token operator">=</span><span class="token punctuation">]</span> <span class="token keyword"><em class="replaceable">extent_size</em></span><span class="token punctuation">]</span>
    <span class="token punctuation">[</span><span class="token keyword">INITIAL_SIZE</span> <span class="token punctuation">[</span><span class="token operator">=</span><span class="token punctuation">]</span> <span class="token keyword"><em class="replaceable">initial_size</em></span><span class="token punctuation">]</span>
    <span class="token punctuation">[</span><span class="token keyword">MAX_SIZE</span> <span class="token punctuation">[</span><span class="token operator">=</span><span class="token punctuation">]</span> <span class="token keyword"><em class="replaceable">max_size</em></span><span class="token punctuation">]</span>
    <span class="token punctuation">[</span><span class="token keyword">NODEGROUP</span> <span class="token punctuation">[</span><span class="token operator">=</span><span class="token punctuation">]</span> <em class="replaceable">nodegroup_id</em><span class="token punctuation">]</span>
    <span class="token punctuation">[</span><span class="token keyword">WAIT</span><span class="token punctuation">]</span>
    <span class="token punctuation">[</span><span class="token keyword">COMMENT</span> <span class="token punctuation">[</span><span class="token operator">=</span><span class="token punctuation">]</span> <span class="token string">'<em class="replaceable">string</em>'</span><span class="token punctuation">]</span>

  <em>InnoDB <span class="token operator">and</span> <span class="token keyword">NDB</span>:</em>
    <span class="token punctuation">[</span><span class="token keyword">ENGINE</span> <span class="token punctuation">[</span><span class="token operator">=</span><span class="token punctuation">]</span> <em class="replaceable">engine_name</em><span class="token punctuation">]</span>

  <em>Reserved <span class="token keyword">for</span> future <span class="token keyword">use</span>:</em>
    <span class="token punctuation">[</span><span class="token keyword">ENGINE_ATTRIBUTE</span> <span class="token punctuation">[</span><span class="token operator">=</span><span class="token punctuation">]</span> <span class="token string">'<em class="replaceable">string</em>'</span><span class="token punctuation">]</span></code></pre>
  </div>
  <p>
   This statement is used to create a tablespace. The precise syntax
      and semantics depend on the storage engine used. In standard MySQL
      releases, this is always an
   <a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
    <code class="literal">
     InnoDB
    </code>
   </a>
   tablespace. MySQL NDB Cluster also supports tablespaces using the
   <a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
    <code class="literal">
     NDB
    </code>
   </a>
   storage engine.
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="xref" href="create-tablespace.html#create-tablespace-innodb" title="Considerations for InnoDB">
       Considerations for InnoDB
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="create-tablespace.html#create-tablespace-ndb" title="Considerations for NDB Cluster">
       Considerations for NDB Cluster
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="create-tablespace.html#create-tablespace-options" title="Options">
       Options
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="create-tablespace.html#create-tablespace-notes" title="Notes">
       Notes
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="create-tablespace.html#create-tablespace-innodb-examples" title="InnoDB Examples">
       InnoDB Examples
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="create-tablespace.html#create-tablespace-ndb-examples" title="NDB Example">
       NDB Example
      </a>
     </p>
    </li>
   </ul>
  </div>
  <h4>
   <a name="create-tablespace-innodb">
   </a>
   Considerations for InnoDB
  </h4>
  <p>
   <a class="link" href="create-tablespace.html" title="15.1.21 CREATE TABLESPACE Statement">
    <code class="literal">
     CREATE TABLESPACE
    </code>
   </a>
   syntax is used to
      create general tablespaces or undo tablespaces. The
   <code class="literal">
    UNDO
   </code>
   keyword must be specified to create an
      undo tablespace.
  </p>
  <p>
   A general tablespace is a shared tablespace. It can hold multiple
      tables, and supports all table row formats. General tablespaces
      can be created in a location relative to or independent of the
      data directory.
  </p>
  <p>
   After creating an
   <code class="literal">
    InnoDB
   </code>
   general tablespace,
      use
   <a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
    <code class="literal">
     CREATE TABLE
     <em class="replaceable">
      <code>
       tbl_name
      </code>
     </em>
     ... TABLESPACE [=]
     <em class="replaceable">
      <code>
       tablespace_name
      </code>
     </em>
    </code>
   </a>
   or
   <a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
    <code class="literal">
     ALTER TABLE
     <em class="replaceable">
      <code>
       tbl_name
      </code>
     </em>
     TABLESPACE [=]
     <em class="replaceable">
      <code>
       tablespace_name
      </code>
     </em>
    </code>
   </a>
   to add tables
      to the tablespace. For more information, see
   <a class="xref" href="general-tablespaces.html" title="17.6.3.3 General Tablespaces">
    Section 17.6.3.3, “General Tablespaces”
   </a>
   .
  </p>
  <p>
   Undo tablespaces contain undo logs. Undo tablespaces can be
      created in a chosen location by specifying a fully qualified data
      file path. For more information, see
   <a class="xref" href="innodb-undo-tablespaces.html" title="17.6.3.4 Undo Tablespaces">
    Section 17.6.3.4, “Undo Tablespaces”
   </a>
   .
  </p>
  <h4>
   <a name="create-tablespace-ndb">
   </a>
   Considerations for NDB Cluster
  </h4>
  <p>
   This statement is used to create a tablespace, which can contain
      one or more data files, providing storage space for NDB Cluster
      Disk Data tables (see
   <a class="xref" href="mysql-cluster-disk-data.html" title="25.6.11 NDB Cluster Disk Data Tables">
    Section 25.6.11, “NDB Cluster Disk Data Tables”
   </a>
   ).
      One data file is created and added to the tablespace using this
      statement. Additional data files may be added to the tablespace by
      using the
   <a class="link" href="alter-tablespace.html" title="15.1.10 ALTER TABLESPACE Statement">
    <code class="literal">
     ALTER TABLESPACE
    </code>
   </a>
   statement (see
   <a class="xref" href="alter-tablespace.html" title="15.1.10 ALTER TABLESPACE Statement">
    Section 15.1.10, “ALTER TABLESPACE Statement”
   </a>
   ).
  </p>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    All NDB Cluster Disk Data objects share the same namespace. This
        means that
    <span class="emphasis">
     <em>
      each Disk Data object
     </em>
    </span>
    must be
        uniquely named (and not merely each Disk Data object of a given
        type). For example, you cannot have a tablespace and a log file
        group with the same name, or a tablespace and a data file with
        the same name.
   </p>
  </div>
  <p>
   A log file group of one or more
   <code class="literal">
    UNDO
   </code>
   log files
      must be assigned to the tablespace to be created with the
   <code class="literal">
    USE LOGFILE GROUP
   </code>
   clause.
   <em class="replaceable">
    <code>
     logfile_group
    </code>
   </em>
   must be an existing log
      file group created with
   <a class="link" href="create-logfile-group.html" title="15.1.16 CREATE LOGFILE GROUP Statement">
    <code class="literal">
     CREATE LOGFILE
      GROUP
    </code>
   </a>
   (see
   <a class="xref" href="create-logfile-group.html" title="15.1.16 CREATE LOGFILE GROUP Statement">
    Section 15.1.16, “CREATE LOGFILE GROUP Statement”
   </a>
   ).
      Multiple tablespaces may use the same log file group for
   <code class="literal">
    UNDO
   </code>
   logging.
  </p>
  <p>
   When setting
   <code class="literal">
    EXTENT_SIZE
   </code>
   or
   <code class="literal">
    INITIAL_SIZE
   </code>
   , you may optionally follow the
      number with a one-letter abbreviation for an order of magnitude,
      similar to those used in
   <code class="filename">
    my.cnf
   </code>
   . Generally,
      this is one of the letters
   <code class="literal">
    M
   </code>
   (for megabytes) or
   <code class="literal">
    G
   </code>
   (for gigabytes).
  </p>
  <p>
   <code class="literal">
    INITIAL_SIZE
   </code>
   and
   <code class="literal">
    EXTENT_SIZE
   </code>
   are subject to rounding as follows:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <code class="literal">
       EXTENT_SIZE
      </code>
      is rounded up to the nearest
          whole multiple of 32K.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       INITIAL_SIZE
      </code>
      is rounded
      <span class="emphasis">
       <em>
        down
       </em>
      </span>
      to the nearest whole multiple of
          32K; this result is rounded up to the nearest whole multiple
          of
      <code class="literal">
       EXTENT_SIZE
      </code>
      (after any rounding).
     </p>
    </li>
   </ul>
  </div>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    <a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
     <code class="literal">
      NDB
     </code>
    </a>
    reserves 4% of a tablespace for
        data node restart operations. This reserved space cannot be used
        for data storage.
   </p>
  </div>
  <p>
   The rounding just described is done explicitly, and a warning is
      issued by the MySQL Server when any such rounding is performed.
      The rounded values are also used by the NDB kernel for calculating
   <a class="link" href="information-schema-files-table.html" title="28.3.15 The INFORMATION_SCHEMA FILES Table">
    <code class="literal">
     INFORMATION_SCHEMA.FILES
    </code>
   </a>
   column
      values and other purposes. However, to avoid an unexpected result,
      we suggest that you always use whole multiples of 32K in
      specifying these options.
  </p>
  <p>
   When
   <a class="link" href="create-tablespace.html" title="15.1.21 CREATE TABLESPACE Statement">
    <code class="literal">
     CREATE TABLESPACE
    </code>
   </a>
   is used with
   <code class="literal">
    ENGINE [=] NDB
   </code>
   , a tablespace and associated
      data file are created on each Cluster data node. You can verify
      that the data files were created and obtain information about them
      by querying the Information Schema
   <a class="link" href="information-schema-files-table.html" title="28.3.15 The INFORMATION_SCHEMA FILES Table">
    <code class="literal">
     FILES
    </code>
   </a>
   table. (See the example later
      in this section.)
  </p>
  <p>
   (See
   <a class="xref" href="information-schema-files-table.html" title="28.3.15 The INFORMATION_SCHEMA FILES Table">
    Section 28.3.15, “The INFORMATION_SCHEMA FILES Table”
   </a>
   .)
  </p>
  <h4>
   <a name="create-tablespace-options">
   </a>
   Options
  </h4>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <code class="literal">
       ADD DATAFILE
      </code>
      : Defines the name of a
          tablespace data file. This option is always required when
          creating an
      <code class="literal">
       NDB
      </code>
      tablespace; for
      <code class="literal">
       InnoDB
      </code>
      , it is required only when creating
          an undo tablespace. The
      <code class="literal">
       <em class="replaceable">
        <code>
         file_name
        </code>
       </em>
      </code>
      ,
          including any specified path, must be quoted with single or
          double quotation marks. File names (not counting the file
          extension) and directory names must be at least one byte in
          length. Zero length file names and directory names are not
          supported.
     </p>
     <p>
      Because there are considerable differences in how
      <code class="literal">
       InnoDB
      </code>
      and
      <code class="literal">
       NDB
      </code>
      treat
          data files, the two storage engines are covered separately in
          the discussion that follows.
     </p>
     <p>
      <b>
       InnoDB data files.
      </b>
      An
      <code class="literal">
       InnoDB
      </code>
      tablespace supports only a
            single data file, whose name must include an
      <code class="filename">
       .ibd
      </code>
      extension.
     </p>
     <p>
      To place an
      <code class="literal">
       InnoDB
      </code>
      general tablespace data
          file in a location outside of the data directory, include a
          fully qualified path or a path relative to the data directory.
          Only a fully qualified path is permitted for undo tablespaces.
          If you do not specify a path, a general tablespace is created
          in the data directory. An undo tablespace created without
          specifying a path is created in the directory defined by the
      <a class="link" href="innodb-parameters.html#sysvar_innodb_undo_directory">
       <code class="literal">
        innodb_undo_directory
       </code>
      </a>
      variable. If
      <code class="literal">
       innodb_undo_directory
      </code>
      is not
          set, undo tablespaces are created in the data directory.
     </p>
     <p>
      To avoid conflicts with implicitly created file-per-table
          tablespaces, creating an
      <code class="literal">
       InnoDB
      </code>
      general
          tablespace in a subdirectory under the data directory is not
          supported. When creating a general tablespace or undo
          tablespace outside of the data directory, the directory must
          exist and must be known to
      <code class="literal">
       InnoDB
      </code>
      prior to
          creating the tablespace. To make a directory known to
      <code class="literal">
       InnoDB
      </code>
      , add it to the
      <a class="link" href="innodb-parameters.html#sysvar_innodb_directories">
       <code class="literal">
        innodb_directories
       </code>
      </a>
      value or
          to one of the variables whose values are appended to the value
          of
      <code class="literal">
       innodb_directories
      </code>
      .
      <code class="literal">
       innodb_directories
      </code>
      is a read-only variable.
          Configuring it requires restarting the server.
     </p>
     <p>
      If the
      <code class="literal">
       ADD DATAFILE
      </code>
      clause is not specified
          when creating an
      <code class="literal">
       InnoDB
      </code>
      tablespace, a
          tablespace data file with a unique file name is created
          implicitly. The unique file name is a 128 bit UUID formatted
          into five groups of hexadecimal numbers separated by dashes
          (
      <em class="replaceable">
       <code>
        aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee
       </code>
      </em>
      ).
          A file extension is added if required by the storage engine.
          An
      <code class="filename">
       .ibd
      </code>
      file extension is added for
      <code class="literal">
       InnoDB
      </code>
      general tablespace data files. In a
          replication environment, the data file name created on the
          replication source server is not the same as the data file
          name created on the replica.
     </p>
     <p>
      The
      <code class="literal">
       ADD DATAFILE
      </code>
      clause does not permit
          circular directory references when creating an
      <code class="literal">
       InnoDB
      </code>
      tablespace. For example, the
          circular directory reference (
      <code class="literal">
       /../
      </code>
      ) in the
          following statement is not permitted:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa4055276"><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">TABLESPACE</span> ts1 <span class="token keyword">ADD</span> <span class="token keyword">DATAFILE</span> ts1<span class="token punctuation">.</span>ibd <span class="token string">'<em class="replaceable">any_directory</em>/../ts1.ibd'</span><span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      An exception to this restriction exists on Linux, where a
          circular directory reference is permitted if the preceding
          directory is a symbolic link. For example, the data file path
          in the example above is permitted if
      <em class="replaceable">
       <code>
        any_directory
       </code>
      </em>
      is a symbolic link.
          (It is still permitted for data file paths to begin with
          '
      <code class="literal">
       ../
      </code>
      '.)
     </p>
     <p>
      <b>
       NDB data files.
      </b>
      An
      <code class="literal">
       NDB
      </code>
      tablespace supports multiple data
            files which can have any legal file names; more data files
            can be added to an NDB Cluster tablespace following its
            creation by using an
      <a class="link" href="alter-tablespace.html" title="15.1.10 ALTER TABLESPACE Statement">
       <code class="literal">
        ALTER
            TABLESPACE
       </code>
      </a>
      statement.
     </p>
     <p>
      An
      <code class="literal">
       NDB
      </code>
      tablespace data file is created by
          default in the data node file system directory—that is,
          the directory named
      <code class="filename">
       ndb_
       <em class="replaceable">
        <code>
         nodeid
        </code>
       </em>
       _fs/TS
      </code>
      under the data node's data directory
          (
      <a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-datadir">
       <code class="literal">
        DataDir
       </code>
      </a>
      ), where
      <em class="replaceable">
       <code>
        nodeid
       </code>
      </em>
      is the data node's
      <a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-nodeid">
       <code class="literal">
        NodeId
       </code>
      </a>
      . To place the
          data file in a location other than the default, include an
          absolute directory path or a path relative to the default
          location. If the directory specified does not exist,
      <code class="literal">
       NDB
      </code>
      attempts to create it; the system user
          account under which the data node process is running must have
          the appropriate permissions to do so.
     </p>
     <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
      <div class="admon-title">
       Note
      </div>
      <p>
       When determining the path used for a data file,
       <code class="literal">
        NDB
       </code>
       does not expand the
       <code class="literal">
        ~
       </code>
       (tilde) character.
      </p>
     </div>
     <p>
      When multiple data nodes are run on the same physical host,
          the following considerations apply:
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         You cannot specify an absolute path when creating a data
              file.
        </p>
       </li>
       <li class="listitem">
        <p>
         It is not possible to create tablespace data files outside
              the data node file system directory, unless each data node
              has a separate data directory.
        </p>
       </li>
       <li class="listitem">
        <p>
         If each data node has its own data directory, data files
              can be created anywhere within this directory.
        </p>
       </li>
       <li class="listitem">
        <p>
         If each data node has its own data directory, it may also
              be possible to create a data file outside the node's
              data directory using a relative path, as long as this path
              resolves to a unique location on the host file system for
              each data node running on that host.
        </p>
       </li>
      </ul>
     </div>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       FILE_BLOCK_SIZE
      </code>
      : This option—which is
          specific to
      <code class="literal">
       InnoDB
      </code>
      general tablespaces, and
          is ignored by
      <code class="literal">
       NDB
      </code>
      —defines the block
          size for the tablespace data file. Values can be specified in
          bytes or kilobytes. For example, an 8 kilobyte file block size
          can be specified as 8192 or 8K. If you do not specify this
          option,
      <code class="literal">
       FILE_BLOCK_SIZE
      </code>
      defaults to the
      <a class="link" href="innodb-parameters.html#sysvar_innodb_page_size">
       <code class="literal">
        innodb_page_size
       </code>
      </a>
      value.
      <code class="literal">
       FILE_BLOCK_SIZE
      </code>
      is required when you intend
          to use the tablespace for storing compressed
      <code class="literal">
       InnoDB
      </code>
      tables
          (
      <code class="literal">
       ROW_FORMAT=COMPRESSED
      </code>
      ). In this case, you
          must define the tablespace
      <code class="literal">
       FILE_BLOCK_SIZE
      </code>
      when creating the tablespace.
     </p>
     <p>
      If
      <code class="literal">
       FILE_BLOCK_SIZE
      </code>
      is equal the
      <a class="link" href="innodb-parameters.html#sysvar_innodb_page_size">
       <code class="literal">
        innodb_page_size
       </code>
      </a>
      value, the
          tablespace can contain only tables having an uncompressed row
          format (
      <code class="literal">
       COMPACT
      </code>
      ,
      <code class="literal">
       REDUNDANT
      </code>
      , and
      <code class="literal">
       DYNAMIC
      </code>
      ).
          Tables with a
      <code class="literal">
       COMPRESSED
      </code>
      row format have a
          different physical page size than uncompressed tables.
          Therefore, compressed tables cannot coexist in the same
          tablespace as uncompressed tables.
     </p>
     <p>
      For a general tablespace to contain compressed tables,
      <code class="literal">
       FILE_BLOCK_SIZE
      </code>
      must be specified, and the
      <code class="literal">
       FILE_BLOCK_SIZE
      </code>
      value must be a valid
          compressed page size in relation to the
      <a class="link" href="innodb-parameters.html#sysvar_innodb_page_size">
       <code class="literal">
        innodb_page_size
       </code>
      </a>
      value. Also,
          the physical page size of the compressed table
          (
      <code class="literal">
       KEY_BLOCK_SIZE
      </code>
      ) must be equal to
      <code class="literal">
       FILE_BLOCK_SIZE/1024
      </code>
      . For example, if
      <a class="link" href="innodb-parameters.html#sysvar_innodb_page_size">
       <code class="literal">
        innodb_page_size=16K
       </code>
      </a>
      , and
      <code class="literal">
       FILE_BLOCK_SIZE=8K
      </code>
      , the
      <code class="literal">
       KEY_BLOCK_SIZE
      </code>
      of the table must be 8. For
          more information, see
      <a class="xref" href="general-tablespaces.html" title="17.6.3.3 General Tablespaces">
       Section 17.6.3.3, “General Tablespaces”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       USE LOGFILE GROUP
      </code>
      : Required for
      <code class="literal">
       NDB
      </code>
      , this is the name of a log file group
          previously created using
      <a class="link" href="create-logfile-group.html" title="15.1.16 CREATE LOGFILE GROUP Statement">
       <code class="literal">
        CREATE LOGFILE
          GROUP
       </code>
      </a>
      . Not supported for
      <code class="literal">
       InnoDB
      </code>
      ,
          where it fails with an error.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       EXTENT_SIZE
      </code>
      : This option is specific to
          NDB, and is not supported by InnoDB, where it fails with an
          error.
      <code class="literal">
       EXTENT_SIZE
      </code>
      sets the size, in bytes,
          of the extents used by any files belonging to the tablespace.
          The default value is 1M. The minimum size is 32K, and
          theoretical maximum is 2G, although the practical maximum size
          depends on a number of factors. In most cases, changing the
          extent size does not have any measurable effect on
          performance, and the default value is recommended for all but
          the most unusual situations.
     </p>
     <p>
      An
      <span class="firstterm">
       extent
      </span>
      is a unit of
          disk space allocation. One extent is filled with as much data
          as that extent can contain before another extent is used. In
          theory, up to 65,535 (64K) extents may used per data file;
          however, the recommended maximum is 32,768 (32K). The
          recommended maximum size for a single data file is
          32G—that is, 32K extents × 1 MB per extent. In
          addition, once an extent is allocated to a given partition, it
          cannot be used to store data from a different partition; an
          extent cannot store data from more than one partition. This
          means, for example that a tablespace having a single datafile
          whose
      <code class="literal">
       INITIAL_SIZE
      </code>
      (described in the
          following item) is 256 MB and whose
      <code class="literal">
       EXTENT_SIZE
      </code>
      is 128M has just two extents,
          and so can be used to store data from at most two different
          disk data table partitions.
     </p>
     <p>
      You can see how many extents remain free in a given data file
          by querying the Information Schema
      <a class="link" href="information-schema-files-table.html" title="28.3.15 The INFORMATION_SCHEMA FILES Table">
       <code class="literal">
        FILES
       </code>
      </a>
      table, and so derive an
          estimate for how much space remains free in the file. For
          further discussion and examples, see
      <a class="xref" href="information-schema-files-table.html" title="28.3.15 The INFORMATION_SCHEMA FILES Table">
       Section 28.3.15, “The INFORMATION_SCHEMA FILES Table”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       INITIAL_SIZE
      </code>
      : This option is specific to
      <code class="literal">
       NDB
      </code>
      , and is not supported by
      <code class="literal">
       InnoDB
      </code>
      , where it fails with an error.
     </p>
     <p>
      The
      <code class="literal">
       INITIAL_SIZE
      </code>
      parameter sets the total
          size in bytes of the data file that was specific using
      <code class="literal">
       ADD DATATFILE
      </code>
      . Once this file has been
          created, its size cannot be changed; however, you can add more
          data files to the tablespace using
      <a class="link" href="alter-tablespace.html" title="15.1.10 ALTER TABLESPACE Statement">
       <code class="literal">
        ALTER
          TABLESPACE ... ADD DATAFILE
       </code>
      </a>
      .
     </p>
     <p>
      <code class="literal">
       INITIAL_SIZE
      </code>
      is optional; its default value
          is 134217728 (128 MB).
     </p>
     <p>
      On 32-bit systems, the maximum supported value for
      <code class="literal">
       INITIAL_SIZE
      </code>
      is 4294967296 (4 GB).
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       AUTOEXTEND_SIZE
      </code>
      : Defines the amount by
          which
      <code class="literal">
       InnoDB
      </code>
      extends the size of the
          tablespace when it becomes full. The setting must be a
          multiple of 4MB. The default setting is 0, which causes the
          tablespace to be extended according to the implicit default
          behavior. For more information, see
      <a class="xref" href="innodb-tablespace-autoextend-size.html" title="17.6.3.9 Tablespace AUTOEXTEND_SIZE Configuration">
       Section 17.6.3.9, “Tablespace AUTOEXTEND_SIZE Configuration”
      </a>
      .
     </p>
     <p>
      Has no effect in any release of MySQL NDB Cluster, regardless
          of the storage engine used.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       MAX_SIZE
      </code>
      : Currently ignored by MySQL;
          reserved for possible future use. Has no effect in any release
          of MySQL or MySQL NDB Cluster, regardless of the storage
          engine used.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       NODEGROUP
      </code>
      : Currently ignored by MySQL;
          reserved for possible future use. Has no effect in any release
          of MySQL or MySQL NDB Cluster, regardless of the storage
          engine used.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       WAIT
      </code>
      : Currently ignored by MySQL; reserved
          for possible future use. Has no effect in any release of MySQL
          or MySQL NDB Cluster, regardless of the storage engine used.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       COMMENT
      </code>
      : Currently ignored by MySQL;
          reserved for possible future use. Has no effect in any release
          of MySQL or MySQL NDB Cluster, regardless of the storage
          engine used.
     </p>
    </li>
    <li class="listitem">
     <p>
      The
      <code class="literal">
       ENCRYPTION
      </code>
      clause enables or disables
          page-level data encryption for an
      <code class="literal">
       InnoDB
      </code>
      general tablespace.
     </p>
     <p>
      If the
      <code class="literal">
       ENCRYPTION
      </code>
      clause is not specified,
          the
      <a class="link" href="server-system-variables.html#sysvar_default_table_encryption">
       <code class="literal">
        default_table_encryption
       </code>
      </a>
      setting controls whether encryption is enabled. The
      <code class="literal">
       ENCRYPTION
      </code>
      clause overrides the
      <a class="link" href="server-system-variables.html#sysvar_default_table_encryption">
       <code class="literal">
        default_table_encryption
       </code>
      </a>
      setting. However, if the
      <a class="link" href="server-system-variables.html#sysvar_table_encryption_privilege_check">
       <code class="literal">
        table_encryption_privilege_check
       </code>
      </a>
      variable is enabled, the
      <a class="link" href="privileges-provided.html#priv_table-encryption-admin">
       <code class="literal">
        TABLE_ENCRYPTION_ADMIN
       </code>
      </a>
      privilege is required to use an
      <code class="literal">
       ENCRYPTION
      </code>
      clause setting that differs from the
      <a class="link" href="server-system-variables.html#sysvar_default_table_encryption">
       <code class="literal">
        default_table_encryption
       </code>
      </a>
      setting.
     </p>
     <p>
      A keyring plugin must be installed and configured before an
          encryption-enabled tablespace can be created.
     </p>
     <p>
      When a general tablespace is encrypted, all tables residing in
          the tablespace are encrypted. Likewise, a table created in an
          encrypted tablespace is encrypted.
     </p>
     <p>
      For more information, see
      <a class="xref" href="innodb-data-encryption.html" title="17.13 InnoDB Data-at-Rest Encryption">
       Section 17.13, “InnoDB Data-at-Rest Encryption”
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       ENGINE
      </code>
      : Defines the storage engine which
          uses the tablespace, where
      <em class="replaceable">
       <code>
        engine_name
       </code>
      </em>
      is the name of the
          storage engine. Currently, only the
      <code class="literal">
       InnoDB
      </code>
      storage engine is supported by standard MySQL 8.4
          releases. MySQL NDB Cluster supports both
      <code class="literal">
       NDB
      </code>
      and
      <code class="literal">
       InnoDB
      </code>
      tablespaces. The value of the
      <a class="link" href="server-system-variables.html#sysvar_default_storage_engine">
       <code class="literal">
        default_storage_engine
       </code>
      </a>
      system
          variable is used for
      <code class="literal">
       ENGINE
      </code>
      if the option
          is not specified.
     </p>
    </li>
    <li class="listitem">
     <p>
      The
      <code class="literal">
       ENGINE_ATTRIBUTE
      </code>
      option is used to
          specify tablespace attributes for primary storage engines. The
          option is reserved for future use.
     </p>
     <p>
      The value assigned to this option must be a string literal
          containing a valid JSON document or an empty string ('').
          Invalid JSON is rejected.
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa4405257"><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">TABLESPACE</span> ts1 <span class="token keyword">ENGINE_ATTRIBUTE</span><span class="token operator">=</span><span class="token string">'{"<em class="replaceable">key</em>":"<em class="replaceable">value</em>"}'</span><span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      <code class="literal">
       ENGINE_ATTRIBUTE
      </code>
      values can be repeated
          without error. In this case, the last specified value is used.
     </p>
     <p>
      <code class="literal">
       ENGINE_ATTRIBUTE
      </code>
      values are not checked by
          the server, nor are they cleared when the table's storage
          engine is changed.
     </p>
    </li>
   </ul>
  </div>
  <h4>
   <a name="create-tablespace-notes">
   </a>
   Notes
  </h4>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      For the rules covering the naming of MySQL tablespaces, see
      <a class="xref" href="identifiers.html" title="11.2 Schema Object Names">
       Section 11.2, “Schema Object Names”
      </a>
      . In addition to these rules, the
          slash character (
      <span class="quote">
       “
       <span class="quote">
        /
       </span>
       ”
      </span>
      ) is not permitted, nor can
          you use names beginning with
      <code class="literal">
       innodb_
      </code>
      , as
          this prefix is reserved for system use.
     </p>
    </li>
    <li class="listitem">
     <p>
      Creation of temporary general tablespaces is not supported.
     </p>
    </li>
    <li class="listitem">
     <p>
      General tablespaces do not support temporary tables.
     </p>
    </li>
    <li class="listitem">
     <p>
      The
      <code class="literal">
       TABLESPACE
      </code>
      option may be used with
      <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>
      to assign an
      <code class="literal">
       InnoDB
      </code>
      table partition or subpartition to a
          file-per-table tablespace. All partitions must belong to the
          same storage engine. Assigning table partitions to shared
      <code class="literal">
       InnoDB
      </code>
      tablespaces is not supported. Shared
          tablespaces include the
      <code class="literal">
       InnoDB
      </code>
      system
          tablespace and general tablespaces.
     </p>
    </li>
    <li class="listitem">
     <p>
      General tablespaces support the addition of tables of any row
          format using
      <a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
       <code class="literal">
        CREATE TABLE ...
          TABLESPACE
       </code>
      </a>
      .
      <a class="link" href="innodb-parameters.html#sysvar_innodb_file_per_table">
       <code class="literal">
        innodb_file_per_table
       </code>
      </a>
      does
          not need to be enabled.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="innodb-parameters.html#sysvar_innodb_strict_mode">
       <code class="literal">
        innodb_strict_mode
       </code>
      </a>
      is not
          applicable to general tablespaces. Tablespace management rules
          are strictly enforced independently of
      <a class="link" href="innodb-parameters.html#sysvar_innodb_strict_mode">
       <code class="literal">
        innodb_strict_mode
       </code>
      </a>
      . If
      <code class="literal">
       CREATE TABLESPACE
      </code>
      parameters are incorrect
          or incompatible, the operation fails regardless of the
      <a class="link" href="innodb-parameters.html#sysvar_innodb_strict_mode">
       <code class="literal">
        innodb_strict_mode
       </code>
      </a>
      setting.
          When a table is added to a general tablespace using
      <a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
       <code class="literal">
        CREATE TABLE ...
          TABLESPACE
       </code>
      </a>
      or
      <a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
       <code class="literal">
        ALTER TABLE ...
          TABLESPACE
       </code>
      </a>
      ,
      <a class="link" href="innodb-parameters.html#sysvar_innodb_strict_mode">
       <code class="literal">
        innodb_strict_mode
       </code>
      </a>
      is ignored
          but the statement is evaluated as if
      <a class="link" href="innodb-parameters.html#sysvar_innodb_strict_mode">
       <code class="literal">
        innodb_strict_mode
       </code>
      </a>
      is
          enabled.
     </p>
    </li>
    <li class="listitem">
     <p>
      Use
      <code class="literal">
       DROP TABLESPACE
      </code>
      to remove a tablespace.
          All tables must be dropped from a tablespace using
      <a class="link" href="drop-table.html" title="15.1.32 DROP TABLE Statement">
       <code class="literal">
        DROP TABLE
       </code>
      </a>
      prior to dropping
          the tablespace. Before dropping an NDB Cluster tablespace you
          must also remove all its data files using one or more
      <a class="link" href="alter-tablespace.html" title="15.1.10 ALTER TABLESPACE Statement">
       <code class="literal">
        ALTER
          TABLESPACE ... DROP DATATFILE
       </code>
      </a>
      statements. See
      <a class="xref" href="mysql-cluster-disk-data-objects.html" title="25.6.11.1 NDB Cluster Disk Data Objects">
       Section 25.6.11.1, “NDB Cluster Disk Data Objects”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      All parts of an
      <code class="literal">
       InnoDB
      </code>
      table added to an
      <code class="literal">
       InnoDB
      </code>
      general tablespace reside in the
          general tablespace, including indexes and
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        BLOB
       </code>
      </a>
      pages.
     </p>
     <p>
      For an
      <code class="literal">
       NDB
      </code>
      table assigned to a tablespace,
          only those columns which are not indexed are stored on disk,
          and actually use the tablespace data files. Indexes and
          indexed columns for all
      <code class="literal">
       NDB
      </code>
      tables are
          always kept in memory.
     </p>
    </li>
    <li class="listitem">
     <p>
      Similar to the system tablespace, truncating or dropping
          tables stored in a general tablespace creates free space
          internally in the general tablespace
      <a class="link" href="glossary.html#glos_ibd_file" title=".ibd file">
       .ibd data file
      </a>
      which can
          only be used for new
      <code class="literal">
       InnoDB
      </code>
      data. Space is
          not released back to the operating system as it is for
          file-per-table tablespaces.
     </p>
    </li>
    <li class="listitem">
     <p>
      A general tablespace is not associated with any database or
          schema.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
       <code class="literal">
        ALTER TABLE ...
          DISCARD TABLESPACE
       </code>
      </a>
      and
      <a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
       <code class="literal">
        ALTER TABLE
          ...IMPORT TABLESPACE
       </code>
      </a>
      are not supported for tables
          that belong to a general tablespace.
     </p>
    </li>
    <li class="listitem">
     <p>
      The server uses tablespace-level metadata locking for DDL that
          references general tablespaces. By comparison, the server uses
          table-level metadata locking for DDL that references
          file-per-table tablespaces.
     </p>
    </li>
    <li class="listitem">
     <p>
      A generated or existing tablespace cannot be changed to a
          general tablespace.
     </p>
    </li>
    <li class="listitem">
     <p>
      There is no conflict between general tablespace names and
          file-per-table tablespace names. The
      <span class="quote">
       “
       <span class="quote">
        /
       </span>
       ”
      </span>
      character, which is present in file-per-table tablespace
          names, is not permitted in general tablespace names.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
       <span class="command">
        <strong>
         mysqldump
        </strong>
       </span>
      </a>
      does not dump
      <code class="literal">
       InnoDB
      </code>
      <a class="link" href="create-tablespace.html" title="15.1.21 CREATE TABLESPACE Statement">
       <code class="literal">
        CREATE
          TABLESPACE
       </code>
      </a>
      statements.
     </p>
    </li>
   </ul>
  </div>
  <h4>
   <a name="create-tablespace-innodb-examples">
   </a>
   InnoDB Examples
  </h4>
  <p>
   This example demonstrates creating a general tablespace and adding
      three uncompressed tables of different row formats.
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa15168896"><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">TABLESPACE</span> <span class="token punctuation">`</span>ts1<span class="token punctuation">`</span> <span class="token keyword">ADD</span> <span class="token keyword">DATAFILE</span> <span class="token string">'ts1.ibd'</span> <span class="token keyword">ENGINE</span><span class="token operator">=</span>INNODB<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 keyword">PRIMARY</span> <span class="token keyword">KEY</span><span class="token punctuation">)</span> <span class="token keyword">TABLESPACE</span> ts1 <span class="token keyword">ROW_FORMAT</span><span class="token operator">=</span><span class="token keyword">REDUNDANT</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> t2 <span class="token punctuation">(</span>c1 <span class="token datatype">INT</span> <span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span><span class="token punctuation">)</span> <span class="token keyword">TABLESPACE</span> ts1 <span class="token keyword">ROW_FORMAT</span><span class="token operator">=</span><span class="token keyword">COMPACT</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> t3 <span class="token punctuation">(</span>c1 <span class="token datatype">INT</span> <span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span><span class="token punctuation">)</span> <span class="token keyword">TABLESPACE</span> ts1 <span class="token keyword">ROW_FORMAT</span><span class="token operator">=</span><span class="token keyword">DYNAMIC</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   This example demonstrates creating a general tablespace and adding
      a compressed table. The example assumes a default
   <a class="link" href="innodb-parameters.html#sysvar_innodb_page_size">
    <code class="literal">
     innodb_page_size
    </code>
   </a>
   value of 16K.
      The
   <code class="literal">
    FILE_BLOCK_SIZE
   </code>
   of 8192 requires that the
      compressed table have a
   <code class="literal">
    KEY_BLOCK_SIZE
   </code>
   of 8.
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa95626162"><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">TABLESPACE</span> <span class="token punctuation">`</span>ts2<span class="token punctuation">`</span> <span class="token keyword">ADD</span> <span class="token keyword">DATAFILE</span> <span class="token string">'ts2.ibd'</span> <span class="token keyword">FILE_BLOCK_SIZE</span> <span class="token operator">=</span> <span class="token number">8192</span> <span class="token keyword">ENGINE</span><span class="token operator">=</span>InnoDB<span class="token punctuation">;</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t4 <span class="token punctuation">(</span>c1 <span class="token datatype">INT</span> <span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span><span class="token punctuation">)</span> <span class="token keyword">TABLESPACE</span> ts2 <span class="token keyword">ROW_FORMAT</span><span class="token operator">=</span><span class="token keyword">COMPRESSED</span> <span class="token keyword">KEY_BLOCK_SIZE</span><span class="token operator">=</span><span class="token number">8</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   This example demonstrates creating a general tablespace without
      specifying the
   <code class="literal">
    ADD DATAFILE
   </code>
   clause, which is
      optional:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa7786188"><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">TABLESPACE</span> <span class="token punctuation">`</span>ts3<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>
  <p>
   This example demonstrates creating an undo tablespace:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa12847076"><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">UNDO</span> <span class="token keyword">TABLESPACE</span> <em class="replaceable">undo_003</em> <span class="token keyword">ADD</span> <span class="token keyword">DATAFILE</span> <span class="token string">'<em class="replaceable">undo_003</em>.ibu'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <h4>
   <a name="create-tablespace-ndb-examples">
   </a>
   NDB Example
  </h4>
  <p>
   Suppose that you wish to create an NDB Cluster Disk Data
      tablespace named
   <code class="literal">
    myts
   </code>
   using a datafile named
   <code class="filename">
    mydata-1.dat
   </code>
   . An
   <code class="filename">
    NDB
   </code>
   tablespace always requires the use of a log file group consisting
      of one or more undo log files. For this example, we first create a
      log file group named
   <code class="literal">
    mylg
   </code>
   that contains one
      undo long file named
   <code class="filename">
    myundo-1.dat
   </code>
   , using the
   <a class="link" href="create-logfile-group.html" title="15.1.16 CREATE LOGFILE GROUP Statement">
    <code class="literal">
     CREATE LOGFILE GROUP
    </code>
   </a>
   statement
      shown here:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa28439111"><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">LOGFILE</span> <span class="token keyword">GROUP</span> myg1
<span class="token prompt">    -&gt;</span>     <span class="token keyword">ADD</span> <span class="token keyword">UNDOFILE</span> <span class="token string">'myundo-1.dat'</span>
<span class="token prompt">    -&gt;</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 (3.29 sec)</span></code></pre>
  </div>
  <p>
   Now you can create the tablespace previously described using the
      following statement:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa47420122"><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">TABLESPACE</span> myts
<span class="token prompt">    -&gt;</span>     <span class="token keyword">ADD</span> <span class="token keyword">DATAFILE</span> <span class="token string">'mydata-1.dat'</span>
<span class="token prompt">    -&gt;</span>     <span class="token keyword">USE</span> <span class="token keyword">LOGFILE</span> <span class="token keyword">GROUP</span> mylg
<span class="token prompt">    -&gt;</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.98 sec)</span></code></pre>
  </div>
  <p>
   You can now create a Disk Data table using a
   <a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
    <code class="literal">
     CREATE TABLE
    </code>
   </a>
   statement with the
   <code class="literal">
    TABLESPACE
   </code>
   and
   <code class="literal">
    STORAGE DISK
   </code>
   options, similar to what is shown here:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa78349316"><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> mytable <span class="token punctuation">(</span>
<span class="token prompt">    -&gt;</span>     id <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 keyword">AUTO_INCREMENT</span> <span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span><span class="token punctuation">,</span>
<span class="token prompt">    -&gt;</span>     lname <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">50</span><span class="token punctuation">)</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
<span class="token prompt">    -&gt;</span>     fname <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">50</span><span class="token punctuation">)</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
<span class="token prompt">    -&gt;</span>     dob <span class="token datatype">DATE</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
<span class="token prompt">    -&gt;</span>     joined <span class="token datatype">DATE</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
<span class="token prompt">    -&gt;</span>     <span class="token keyword">INDEX</span><span class="token punctuation">(</span>last_name<span class="token punctuation">,</span> first_name<span class="token punctuation">)</span>
<span class="token prompt">    -&gt;</span> <span class="token punctuation">)</span>
<span class="token prompt">    -&gt;</span>     <span class="token keyword">TABLESPACE</span> myts <span class="token keyword">STORAGE</span> <span class="token keyword">DISK</span>
<span class="token prompt">    -&gt;</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.41 sec)</span></code></pre>
  </div>
  <p>
   It is important to note that only the
   <code class="literal">
    dob
   </code>
   and
   <code class="literal">
    joined
   </code>
   columns from
   <code class="literal">
    mytable
   </code>
   are actually stored on disk, due to the fact that the
   <code class="literal">
    id
   </code>
   ,
   <code class="literal">
    lname
   </code>
   , and
   <code class="literal">
    fname
   </code>
   columns are all indexed.
  </p>
  <p>
   As mentioned previously, when
   <code class="literal">
    CREATE TABLESPACE
   </code>
   is used with
   <code class="literal">
    ENGINE [=] NDB
   </code>
   , a tablespace and
      its associated data file are created on each NDB Cluster data
      node. You can verify that the data files were created and obtain
      information about them by querying the Information Schema
   <a class="link" href="information-schema-files-table.html" title="28.3.15 The INFORMATION_SCHEMA FILES Table">
    <code class="literal">
     FILES
    </code>
   </a>
   table, as shown here:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa25931024"><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">SELECT</span> FILE_NAME<span class="token punctuation">,</span> FILE_TYPE<span class="token punctuation">,</span> LOGFILE_GROUP_NAME<span class="token punctuation">,</span> <span class="token keyword">STATUS</span><span class="token punctuation">,</span> EXTRA
<span class="token prompt">    -&gt;</span>     <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>FILES
<span class="token prompt">    -&gt;</span>     <span class="token keyword">WHERE</span> TABLESPACE_NAME <span class="token operator">=</span> <span class="token string">'myts'</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><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> file_name    <span class="token punctuation">|</span> file_type  <span class="token punctuation">|</span> logfile_group_name <span class="token punctuation">|</span> status <span class="token punctuation">|</span> extra          <span class="token punctuation">|</span></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><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> mydata<span class="token punctuation">-</span>1.dat <span class="token punctuation">|</span> DATAFILE   <span class="token punctuation">|</span> mylg               <span class="token punctuation">|</span> NORMAL <span class="token punctuation">|</span> CLUSTER_NODE=5 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> mydata<span class="token punctuation">-</span>1.dat <span class="token punctuation">|</span> DATAFILE   <span class="token punctuation">|</span> mylg               <span class="token punctuation">|</span> NORMAL <span class="token punctuation">|</span> CLUSTER_NODE=6 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> NULL         <span class="token punctuation">|</span> TABLESPACE <span class="token punctuation">|</span> mylg               <span class="token punctuation">|</span> NORMAL <span class="token punctuation">|</span> NULL           <span class="token punctuation">|</span></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><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">3 rows in set (0.01 sec)</span></code></pre>
  </div>
  <p>
   For additional information and examples, see
   <a class="xref" href="mysql-cluster-disk-data-objects.html" title="25.6.11.1 NDB Cluster Disk Data Objects">
    Section 25.6.11.1, “NDB Cluster Disk Data Objects”
   </a>
   .
  </p>
 </div>
 <br/>
</div>
