<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="string-type-syntax">
      </a>
      13.3.1 String Data Type Syntax
     </h3>
    </div>
   </div>
  </div>
  <p>
   The string data types are
   <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
    <code class="literal">
     CHAR
    </code>
   </a>
   ,
   <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
    <code class="literal">
     VARCHAR
    </code>
   </a>
   ,
   <a class="link" href="binary-varbinary.html" title="13.3.3 The BINARY and VARBINARY Types">
    <code class="literal">
     BINARY
    </code>
   </a>
   ,
   <a class="link" href="binary-varbinary.html" title="13.3.3 The BINARY and VARBINARY Types">
    <code class="literal">
     VARBINARY
    </code>
   </a>
   ,
   <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
    <code class="literal">
     BLOB
    </code>
   </a>
   ,
   <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
    <code class="literal">
     TEXT
    </code>
   </a>
   ,
   <a class="link" href="enum.html" title="13.3.5 The ENUM Type">
    <code class="literal">
     ENUM
    </code>
   </a>
   , and
   <a class="link" href="set.html" title="13.3.6 The SET Type">
    <code class="literal">
     SET
    </code>
   </a>
   .
  </p>
  <p>
   In some cases, MySQL may change a string column to a type
        different from that given 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. See
   <a class="xref" href="silent-column-changes.html" title="15.1.20.7 Silent Column Specification Changes">
    Section 15.1.20.7, “Silent Column Specification Changes”
   </a>
   .
  </p>
  <p>
   For definitions of character string columns
        (
   <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
    <code class="literal">
     CHAR
    </code>
   </a>
   ,
   <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
    <code class="literal">
     VARCHAR
    </code>
   </a>
   , and the
   <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
    <code class="literal">
     TEXT
    </code>
   </a>
   types), MySQL interprets
        length specifications in character units. For definitions of
        binary string columns (
   <a class="link" href="binary-varbinary.html" title="13.3.3 The BINARY and VARBINARY Types">
    <code class="literal">
     BINARY
    </code>
   </a>
   ,
   <a class="link" href="binary-varbinary.html" title="13.3.3 The BINARY and VARBINARY Types">
    <code class="literal">
     VARBINARY
    </code>
   </a>
   , and the
   <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
    <code class="literal">
     BLOB
    </code>
   </a>
   types), MySQL interprets
        length specifications in byte units.
  </p>
  <p>
   Column definitions for character string data types
   <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
    <code class="literal">
     CHAR
    </code>
   </a>
   ,
   <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
    <code class="literal">
     VARCHAR
    </code>
   </a>
   , the
   <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
    <code class="literal">
     TEXT
    </code>
   </a>
   types,
   <a class="link" href="enum.html" title="13.3.5 The ENUM Type">
    <code class="literal">
     ENUM
    </code>
   </a>
   ,
   <a class="link" href="set.html" title="13.3.6 The SET Type">
    <code class="literal">
     SET
    </code>
   </a>
   , and any synonyms) can
        specify the column character set and collation:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <code class="literal">
       CHARACTER SET
      </code>
      specifies the character
            set. If desired, a collation for the character set can be
            specified with the
      <code class="literal">
       COLLATE
      </code>
      attribute,
            along with any other attributes. For example:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa53770851"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t
<span class="token punctuation">(</span>
    c1 <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">20</span><span class="token punctuation">)</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> utf8mb4<span class="token punctuation">,</span>
    c2 <span class="token datatype">TEXT</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> latin1 <span class="token keyword">COLLATE</span> latin1_general_cs
<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      This table definition creates a column named
      <code class="literal">
       c1
      </code>
      that has a character set of
      <code class="literal">
       utf8mb4
      </code>
      with the default collation for
            that character set, and a column named
      <code class="literal">
       c2
      </code>
      that has a character set of
      <code class="literal">
       latin1
      </code>
      and a
            case-sensitive (
      <code class="literal">
       _cs
      </code>
      ) collation.
     </p>
     <p>
      The rules for assigning the character set and collation when
            either or both of
      <code class="literal">
       CHARACTER SET
      </code>
      and the
      <code class="literal">
       COLLATE
      </code>
      attribute are missing are
            described in
      <a class="xref" href="charset-column.html" title="12.3.5 Column Character Set and Collation">
       Section 12.3.5, “Column Character Set and Collation”
      </a>
      .
     </p>
     <p>
      <code class="literal">
       CHARSET
      </code>
      is a synonym for
      <code class="literal">
       CHARACTER SET
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      Specifying the
      <code class="literal">
       CHARACTER SET binary
      </code>
      attribute for a character string data type causes the column
            to be created as the corresponding binary string data type:
      <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
       <code class="literal">
        CHAR
       </code>
      </a>
      becomes
      <a class="link" href="binary-varbinary.html" title="13.3.3 The BINARY and VARBINARY Types">
       <code class="literal">
        BINARY
       </code>
      </a>
      ,
      <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
       <code class="literal">
        VARCHAR
       </code>
      </a>
      becomes
      <a class="link" href="binary-varbinary.html" title="13.3.3 The BINARY and VARBINARY Types">
       <code class="literal">
        VARBINARY
       </code>
      </a>
      , and
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        TEXT
       </code>
      </a>
      becomes
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        BLOB
       </code>
      </a>
      . For the
      <a class="link" href="enum.html" title="13.3.5 The ENUM Type">
       <code class="literal">
        ENUM
       </code>
      </a>
      and
      <a class="link" href="set.html" title="13.3.6 The SET Type">
       <code class="literal">
        SET
       </code>
      </a>
      data types, this does not
            occur; they are created as declared. Suppose that you
            specify a table using this definition:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa57794921"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t
<span class="token punctuation">(</span>
  c1 <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> <span class="token datatype">binary</span><span class="token punctuation">,</span>
  c2 <span class="token datatype">TEXT</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> <span class="token datatype">binary</span><span class="token punctuation">,</span>
  c3 <span class="token datatype">ENUM</span><span class="token punctuation">(</span><span class="token string">'a'</span><span class="token punctuation">,</span><span class="token string">'b'</span><span class="token punctuation">,</span><span class="token string">'c'</span><span class="token punctuation">)</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> <span class="token datatype">binary</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      The resulting table has this definition:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa34965996"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t
<span class="token punctuation">(</span>
  c1 <span class="token datatype">VARBINARY</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
  c2 <span class="token datatype">BLOB</span><span class="token punctuation">,</span>
  c3 <span class="token datatype">ENUM</span><span class="token punctuation">(</span><span class="token string">'a'</span><span class="token punctuation">,</span><span class="token string">'b'</span><span class="token punctuation">,</span><span class="token string">'c'</span><span class="token punctuation">)</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> <span class="token datatype">binary</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      The
      <code class="literal">
       BINARY
      </code>
      attribute is a nonstandard
            MySQL extension that is shorthand for specifying the binary
            (
      <code class="literal">
       _bin
      </code>
      ) collation of the column character
            set (or of the table default character set if no column
            character set is specified). In this case, comparison and
            sorting are based on numeric character code values. Suppose
            that you specify a table using this definition:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa349675"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t
<span class="token punctuation">(</span>
  c1 <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> latin1 <span class="token datatype">BINARY</span><span class="token punctuation">,</span>
  c2 <span class="token datatype">TEXT</span> <span class="token datatype">BINARY</span>
<span class="token punctuation">)</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> utf8mb4<span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      The resulting table has this definition:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa14419717"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t <span class="token punctuation">(</span>
  c1 <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> latin1 <span class="token keyword">COLLATE</span> latin1_bin<span class="token punctuation">,</span>
  c2 <span class="token datatype">TEXT</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> utf8mb4 <span class="token keyword">COLLATE</span> utf8mb4_bin
<span class="token punctuation">)</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> utf8mb4<span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      In MySQL 8.4, the
      <code class="literal">
       BINARY
      </code>
      attribute is deprecated and you should expect support for it
            to be removed in a future version of MySQL. Applications
            should be adjusted to use an explicit
      <code class="literal">
       _bin
      </code>
      collation instead.
     </p>
     <p>
      The use of
      <code class="literal">
       BINARY
      </code>
      to specify a data type
            or character set remains unchanged.
     </p>
    </li>
    <li class="listitem">
     <p>
      The
      <code class="literal">
       ASCII
      </code>
      attribute is shorthand for
      <code class="literal">
       CHARACTER SET latin1
      </code>
      . Supported in older
            MySQL releases,
      <code class="literal">
       ASCII
      </code>
      is deprecated; use
      <code class="literal">
       CHARACTER SET
      </code>
      instead.
     </p>
    </li>
    <li class="listitem">
     <p>
      The
      <code class="literal">
       UNICODE
      </code>
      attribute is shorthand for
      <code class="literal">
       CHARACTER SET ucs2
      </code>
      . Supported in older
            MySQL releases,
      <code class="literal">
       UNICODE
      </code>
      is deprecated;
            use
      <code class="literal">
       CHARACTER SET
      </code>
      instead.
     </p>
    </li>
   </ul>
  </div>
  <p>
   Character column comparison and sorting are based on the
        collation assigned to the column. For the
   <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
    <code class="literal">
     CHAR
    </code>
   </a>
   ,
   <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
    <code class="literal">
     VARCHAR
    </code>
   </a>
   ,
   <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
    <code class="literal">
     TEXT
    </code>
   </a>
   ,
   <a class="link" href="enum.html" title="13.3.5 The ENUM Type">
    <code class="literal">
     ENUM
    </code>
   </a>
   , and
   <a class="link" href="set.html" title="13.3.6 The SET Type">
    <code class="literal">
     SET
    </code>
   </a>
   data types, you can declare a
        column with a binary (
   <code class="literal">
    _bin
   </code>
   ) collation or the
   <code class="literal">
    BINARY
   </code>
   attribute to cause comparison and
        sorting to use the underlying character code values rather than
        a lexical ordering.
  </p>
  <p>
   For additional information about use of character sets in MySQL,
        see
   <a class="xref" href="charset.html" title="Chapter 12 Character Sets, Collations, Unicode">
    Chapter 12,
    <i>
     Character Sets, Collations, Unicode
    </i>
   </a>
   .
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045212994224">
      </a>
      <a class="indexterm" name="idm46045212993152">
      </a>
      <a class="indexterm" name="idm46045212992080">
      </a>
      <a class="indexterm" name="idm46045212991008">
      </a>
      <a class="indexterm" name="idm46045212989936">
      </a>
      <a class="indexterm" name="idm46045212988448">
      </a>
      <a class="indexterm" name="idm46045212986960">
      </a>
      <a class="indexterm" name="idm46045212985472">
      </a>
      <code class="literal">
       [NATIONAL] CHAR[(
       <em class="replaceable">
        <code>
         M
        </code>
       </em>
       )]
            [CHARACTER SET
       <em class="replaceable">
        <code>
         charset_name
        </code>
       </em>
       ]
            [COLLATE
       <em class="replaceable">
        <code>
         collation_name
        </code>
       </em>
       ]
      </code>
     </p>
     <p>
      A fixed-length string that is always right-padded with
            spaces to the specified length when stored.
      <em class="replaceable">
       <code>
        M
       </code>
      </em>
      represents the column length in
            characters. The range of
      <em class="replaceable">
       <code>
        M
       </code>
      </em>
      is 0
            to 255. If
      <em class="replaceable">
       <code>
        M
       </code>
      </em>
      is omitted, the
            length is 1.
     </p>
     <a class="indexterm" name="idm46045212979968">
     </a>
     <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
      <div class="admon-title">
       Note
      </div>
      <p>
       Trailing spaces are removed when
       <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
        <code class="literal">
         CHAR
        </code>
       </a>
       values are retrieved
              unless the
       <a class="link" href="sql-mode.html#sqlmode_pad_char_to_full_length">
        <code class="literal">
         PAD_CHAR_TO_FULL_LENGTH
        </code>
       </a>
       SQL mode is enabled.
      </p>
     </div>
     <p>
      <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
       <code class="literal">
        CHAR
       </code>
      </a>
      is shorthand for
      <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
       <code class="literal">
        CHARACTER
       </code>
      </a>
      .
      <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
       <code class="literal">
        NATIONAL CHAR
       </code>
      </a>
      (or its
            equivalent short form,
      <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
       <code class="literal">
        NCHAR
       </code>
      </a>
      )
            is the standard SQL way to define that a
      <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
       <code class="literal">
        CHAR
       </code>
      </a>
      column should use some
            predefined character set. MySQL uses
      <code class="literal">
       utf8mb3
      </code>
      as this predefined character set.
      <a class="xref" href="charset-national.html" title="12.3.7 The National Character Set">
       Section 12.3.7, “The National Character Set”
      </a>
      .
     </p>
     <p>
      The
      <a class="link" href="binary-varbinary.html" title="13.3.3 The BINARY and VARBINARY Types">
       <code class="literal">
        CHAR BYTE
       </code>
      </a>
      data type is an
            alias for the
      <a class="link" href="binary-varbinary.html" title="13.3.3 The BINARY and VARBINARY Types">
       <code class="literal">
        BINARY
       </code>
      </a>
      data
            type. This is a compatibility feature.
     </p>
     <p>
      MySQL permits you to create a column of type
      <code class="literal">
       CHAR(0)
      </code>
      . This is useful primarily when
            you must be compliant with old applications that depend on
            the existence of a column but that do not actually use its
            value.
      <code class="literal">
       CHAR(0)
      </code>
      is also quite nice when
            you need a column that can take only two values: A column
            that is defined as
      <code class="literal">
       CHAR(0) NULL
      </code>
      occupies
            only one bit and can take only the values
      <code class="literal">
       NULL
      </code>
      and
      <code class="literal">
       ''
      </code>
      (the empty
            string).
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045212953744">
      </a>
      <a class="indexterm" name="idm46045212952672">
      </a>
      <a class="indexterm" name="idm46045212951584">
      </a>
      <a class="indexterm" name="idm46045212950512">
      </a>
      <a class="indexterm" name="idm46045212949440">
      </a>
      <a class="indexterm" name="idm46045212948352">
      </a>
      <a class="indexterm" name="idm46045212947280">
      </a>
      <a class="indexterm" name="idm46045212945792">
      </a>
      <a class="indexterm" name="idm46045212944304">
      </a>
      <a class="indexterm" name="idm46045212942816">
      </a>
      <a class="indexterm" name="idm46045212941328">
      </a>
      <a class="indexterm" name="idm46045212939840">
      </a>
      <code class="literal">
       [NATIONAL] VARCHAR(
       <em class="replaceable">
        <code>
         M
        </code>
       </em>
       )
            [CHARACTER SET
       <em class="replaceable">
        <code>
         charset_name
        </code>
       </em>
       ]
            [COLLATE
       <em class="replaceable">
        <code>
         collation_name
        </code>
       </em>
       ]
      </code>
     </p>
     <a class="indexterm" name="idm46045212936224">
     </a>
     <p>
      A variable-length string.
      <em class="replaceable">
       <code>
        M
       </code>
      </em>
      represents the maximum column length in characters. The
            range of
      <em class="replaceable">
       <code>
        M
       </code>
      </em>
      is 0 to 65,535. The
            effective maximum length of a
      <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
       <code class="literal">
        VARCHAR
       </code>
      </a>
      is subject to the
            maximum row size (65,535 bytes, which is shared among all
            columns) and the character set used. For example,
      <code class="literal">
       utf8mb3
      </code>
      characters can require up to
            three bytes per character, so a
      <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
       <code class="literal">
        VARCHAR
       </code>
      </a>
      column that uses the
      <code class="literal">
       utf8mb3
      </code>
      character set can be declared to
            be a maximum of 21,844 characters. See
      <a class="xref" href="column-count-limit.html" title="10.4.7 Limits on Table Column Count and Row Size">
       Section 10.4.7, “Limits on Table Column Count and Row Size”
      </a>
      .
     </p>
     <p>
      MySQL stores
      <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
       <code class="literal">
        VARCHAR
       </code>
      </a>
      values
            as a 1-byte or 2-byte length prefix plus data. The length
            prefix indicates the number of bytes in the value. A
      <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
       <code class="literal">
        VARCHAR
       </code>
      </a>
      column uses one
            length byte if values require no more than 255 bytes, two
            length bytes if values may require more than 255 bytes.
     </p>
     <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
      <div class="admon-title">
       Note
      </div>
      <p>
       MySQL follows the standard SQL specification, and does
       <span class="emphasis">
        <em>
         not
        </em>
       </span>
       remove trailing spaces from
       <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
        <code class="literal">
         VARCHAR
        </code>
       </a>
       values.
      </p>
     </div>
     <p>
      <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
       <code class="literal">
        VARCHAR
       </code>
      </a>
      is shorthand for
      <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
       <code class="literal">
        CHARACTER VARYING
       </code>
      </a>
      .
      <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
       <code class="literal">
        NATIONAL VARCHAR
       </code>
      </a>
      is the
            standard SQL way to define that a
      <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
       <code class="literal">
        VARCHAR
       </code>
      </a>
      column should use
            some predefined character set. MySQL uses
      <code class="literal">
       utf8mb3
      </code>
      as this predefined character set.
      <a class="xref" href="charset-national.html" title="12.3.7 The National Character Set">
       Section 12.3.7, “The National Character Set”
      </a>
      .
      <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
       <code class="literal">
        NVARCHAR
       </code>
      </a>
      is shorthand for
      <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
       <code class="literal">
        NATIONAL VARCHAR
       </code>
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045212910752">
      </a>
      <a class="indexterm" name="idm46045212909680">
      </a>
      <a class="link" href="binary-varbinary.html" title="13.3.3 The BINARY and VARBINARY Types">
       <code class="literal">
        BINARY[(
        <em class="replaceable">
         <code>
          M
         </code>
        </em>
        )]
       </code>
      </a>
     </p>
     <p>
      The
      <a class="link" href="binary-varbinary.html" title="13.3.3 The BINARY and VARBINARY Types">
       <code class="literal">
        BINARY
       </code>
      </a>
      type is similar to
            the
      <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
       <code class="literal">
        CHAR
       </code>
      </a>
      type, but stores
            binary byte strings rather than nonbinary character strings.
            An optional length
      <em class="replaceable">
       <code>
        M
       </code>
      </em>
      represents
            the column length in bytes. If omitted,
      <em class="replaceable">
       <code>
        M
       </code>
      </em>
      defaults to 1.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045212900064">
      </a>
      <a class="indexterm" name="idm46045212898992">
      </a>
      <a class="link" href="binary-varbinary.html" title="13.3.3 The BINARY and VARBINARY Types">
       <code class="literal">
        VARBINARY(
        <em class="replaceable">
         <code>
          M
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <p>
      The
      <a class="link" href="binary-varbinary.html" title="13.3.3 The BINARY and VARBINARY Types">
       <code class="literal">
        VARBINARY
       </code>
      </a>
      type is similar
            to the
      <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
       <code class="literal">
        VARCHAR
       </code>
      </a>
      type, but
            stores binary byte strings rather than nonbinary character
            strings.
      <em class="replaceable">
       <code>
        M
       </code>
      </em>
      represents the maximum
            column length in bytes.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045212889856">
      </a>
      <a class="indexterm" name="idm46045212888784">
      </a>
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        TINYBLOB
       </code>
      </a>
     </p>
     <p>
      A
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        BLOB
       </code>
      </a>
      column with a maximum
            length of 255 (2
      <sup>
       8
      </sup>
      − 1)
            bytes. Each
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        TINYBLOB
       </code>
      </a>
      value is
            stored using a 1-byte length prefix that indicates the
            number of bytes in the value.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045212879984">
      </a>
      <a class="indexterm" name="idm46045212878912">
      </a>
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        TINYTEXT
            [CHARACTER SET
        <em class="replaceable">
         <code>
          charset_name
         </code>
        </em>
        ]
            [COLLATE
        <em class="replaceable">
         <code>
          collation_name
         </code>
        </em>
        ]
       </code>
      </a>
     </p>
     <p>
      A
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        TEXT
       </code>
      </a>
      column with a maximum
            length of 255 (2
      <sup>
       8
      </sup>
      − 1)
            characters. The effective maximum length is less if the
            value contains multibyte characters. Each
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        TINYTEXT
       </code>
      </a>
      value is stored
            using a 1-byte length prefix that indicates the number of
            bytes in the value.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045212868992">
      </a>
      <a class="indexterm" name="idm46045212867920">
      </a>
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        BLOB[(
        <em class="replaceable">
         <code>
          M
         </code>
        </em>
        )]
       </code>
      </a>
     </p>
     <p>
      A
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        BLOB
       </code>
      </a>
      column with a maximum
            length of 65,535 (2
      <sup>
       16
      </sup>
      − 1)
            bytes. Each
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        BLOB
       </code>
      </a>
      value is
            stored using a 2-byte length prefix that indicates the
            number of bytes in the value.
     </p>
     <p>
      An optional length
      <em class="replaceable">
       <code>
        M
       </code>
      </em>
      can be given
            for this type. If this is done, MySQL creates the column as
            the smallest
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        BLOB
       </code>
      </a>
      type large
            enough to hold values
      <em class="replaceable">
       <code>
        M
       </code>
      </em>
      bytes
            long.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045212856096">
      </a>
      <a class="indexterm" name="idm46045212855024">
      </a>
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        TEXT[(
        <em class="replaceable">
         <code>
          M
         </code>
        </em>
        )]
            [CHARACTER SET
        <em class="replaceable">
         <code>
          charset_name
         </code>
        </em>
        ]
            [COLLATE
        <em class="replaceable">
         <code>
          collation_name
         </code>
        </em>
        ]
       </code>
      </a>
     </p>
     <p>
      A
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        TEXT
       </code>
      </a>
      column with a maximum
            length of 65,535 (2
      <sup>
       16
      </sup>
      − 1)
            characters. The effective maximum length is less if the
            value contains multibyte characters. Each
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        TEXT
       </code>
      </a>
      value is stored using a
            2-byte length prefix that indicates the number of bytes in
            the value.
     </p>
     <p>
      An optional length
      <em class="replaceable">
       <code>
        M
       </code>
      </em>
      can be given
            for this type. If this is done, MySQL creates the column as
            the smallest
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        TEXT
       </code>
      </a>
      type large
            enough to hold values
      <em class="replaceable">
       <code>
        M
       </code>
      </em>
      characters long.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045212842032">
      </a>
      <a class="indexterm" name="idm46045212840960">
      </a>
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        MEDIUMBLOB
       </code>
      </a>
     </p>
     <p>
      A
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        BLOB
       </code>
      </a>
      column with a maximum
            length of 16,777,215 (2
      <sup>
       24
      </sup>
      −
            1) bytes. Each
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        MEDIUMBLOB
       </code>
      </a>
      value is stored using a 3-byte length prefix that indicates
            the number of bytes in the value.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045212832144">
      </a>
      <a class="indexterm" name="idm46045212831072">
      </a>
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        MEDIUMTEXT
            [CHARACTER SET
        <em class="replaceable">
         <code>
          charset_name
         </code>
        </em>
        ]
            [COLLATE
        <em class="replaceable">
         <code>
          collation_name
         </code>
        </em>
        ]
       </code>
      </a>
     </p>
     <p>
      A
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        TEXT
       </code>
      </a>
      column with a maximum
            length of 16,777,215 (2
      <sup>
       24
      </sup>
      −
            1) characters. The effective maximum length is less if the
            value contains multibyte characters. Each
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        MEDIUMTEXT
       </code>
      </a>
      value is stored
            using a 3-byte length prefix that indicates the number of
            bytes in the value.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045212820432">
      </a>
      <a class="indexterm" name="idm46045212819360">
      </a>
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        LONGBLOB
       </code>
      </a>
     </p>
     <p>
      A
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        BLOB
       </code>
      </a>
      column with a maximum
            length of 4,294,967,295 or 4GB
            (2
      <sup>
       32
      </sup>
      − 1) bytes. The
            effective maximum length of
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        LONGBLOB
       </code>
      </a>
      columns depends on
            the configured maximum packet size in the client/server
            protocol and available memory. Each
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        LONGBLOB
       </code>
      </a>
      value is stored
            using a 4-byte length prefix that indicates the number of
            bytes in the value.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045212809088">
      </a>
      <a class="indexterm" name="idm46045212808016">
      </a>
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        LONGTEXT
            [CHARACTER SET
        <em class="replaceable">
         <code>
          charset_name
         </code>
        </em>
        ]
            [COLLATE
        <em class="replaceable">
         <code>
          collation_name
         </code>
        </em>
        ]
       </code>
      </a>
     </p>
     <p>
      A
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        TEXT
       </code>
      </a>
      column with a maximum
            length of 4,294,967,295 or 4GB
            (2
      <sup>
       32
      </sup>
      − 1) characters. The
            effective maximum length is less if the value contains
            multibyte characters. The effective maximum length of
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        LONGTEXT
       </code>
      </a>
      columns also depends on the configured maximum packet size
            in the client/server protocol and available memory. Each
      <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
       <code class="literal">
        LONGTEXT
       </code>
      </a>
      value is stored using a 4-byte length prefix that indicates
            the number of bytes in the value.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045212796640">
      </a>
      <a class="indexterm" name="idm46045212795568">
      </a>
      <a class="link" href="enum.html" title="13.3.5 The ENUM Type">
       <code class="literal">
        ENUM('
        <em class="replaceable">
         <code>
          value1
         </code>
        </em>
        ','
        <em class="replaceable">
         <code>
          value2
         </code>
        </em>
        ',...)
            [CHARACTER SET
        <em class="replaceable">
         <code>
          charset_name
         </code>
        </em>
        ]
            [COLLATE
        <em class="replaceable">
         <code>
          collation_name
         </code>
        </em>
        ]
       </code>
      </a>
     </p>
     <p>
      An enumeration. A string object that can have only one
            value, chosen from the list of values
      <code class="literal">
       '
       <em class="replaceable">
        <code>
         value1
        </code>
       </em>
       '
      </code>
      ,
      <code class="literal">
       '
       <em class="replaceable">
        <code>
         value2
        </code>
       </em>
       '
      </code>
      ,
      <code class="literal">
       ...
      </code>
      ,
      <code class="literal">
       NULL
      </code>
      or the
            special
      <code class="literal">
       ''
      </code>
      error value.
      <a class="link" href="enum.html" title="13.3.5 The ENUM Type">
       <code class="literal">
        ENUM
       </code>
      </a>
      values are represented
            internally as integers.
     </p>
     <p>
      An
      <a class="link" href="enum.html" title="13.3.5 The ENUM Type">
       <code class="literal">
        ENUM
       </code>
      </a>
      column can have a
            maximum of 65,535 distinct elements.
     </p>
     <p>
      The maximum supported length of an individual
      <code class="literal">
       ENUM
      </code>
      element is
      <em class="replaceable">
       <code>
        M
       </code>
      </em>
      &lt;= 255 and
            (
      <em class="replaceable">
       <code>
        M
       </code>
      </em>
      x
      <em class="replaceable">
       <code>
        w
       </code>
      </em>
      ) &lt;= 1020, where
      <code class="literal">
       M
      </code>
      is the element literal length and
      <em class="replaceable">
       <code>
        w
       </code>
      </em>
      is the number of bytes required
            for the maximum-length character in the character set.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045212776848">
      </a>
      <a class="indexterm" name="idm46045212775776">
      </a>
      <a class="link" href="set.html" title="13.3.6 The SET Type">
       <code class="literal">
        SET('
        <em class="replaceable">
         <code>
          value1
         </code>
        </em>
        ','
        <em class="replaceable">
         <code>
          value2
         </code>
        </em>
        ',...)
            [CHARACTER SET
        <em class="replaceable">
         <code>
          charset_name
         </code>
        </em>
        ]
            [COLLATE
        <em class="replaceable">
         <code>
          collation_name
         </code>
        </em>
        ]
       </code>
      </a>
     </p>
     <p>
      A set. A string object that can have zero or more values,
            each of which must be chosen from the list of values
      <code class="literal">
       '
       <em class="replaceable">
        <code>
         value1
        </code>
       </em>
       '
      </code>
      ,
      <code class="literal">
       '
       <em class="replaceable">
        <code>
         value2
        </code>
       </em>
       '
      </code>
      ,
      <code class="literal">
       ...
      </code>
      <a class="link" href="set.html" title="13.3.6 The SET Type">
       <code class="literal">
        SET
       </code>
      </a>
      values are represented internally as integers.
     </p>
     <p>
      A
      <a class="link" href="set.html" title="13.3.6 The SET Type">
       <code class="literal">
        SET
       </code>
      </a>
      column can have a
            maximum of 64 distinct members.
     </p>
     <p>
      The maximum supported length of an individual
      <code class="literal">
       SET
      </code>
      element is
      <em class="replaceable">
       <code>
        M
       </code>
      </em>
      &lt;= 255 and
            (
      <em class="replaceable">
       <code>
        M
       </code>
      </em>
      x
      <em class="replaceable">
       <code>
        w
       </code>
      </em>
      ) &lt;= 1020, where
      <code class="literal">
       M
      </code>
      is the element literal length and
      <em class="replaceable">
       <code>
        w
       </code>
      </em>
      is the number of bytes required
            for the maximum-length character in the character set.
     </p>
    </li>
   </ul>
  </div>
 </div>
 <br/>
</div>
