<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="charset-national">
      </a>
      12.3.7 The National Character Set
     </h3>
    </div>
   </div>
  </div>
  <p>
   Standard SQL defines
   <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
    <code class="literal">
     NCHAR
    </code>
   </a>
   or
   <a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
    <code class="literal">
     NATIONAL CHAR
    </code>
   </a>
   as a way to
        indicate 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">
    utf8
   </code>
   as this predefined character set. For
        example, these data type declarations are equivalent:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa76373317"><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 datatype">CHAR</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> utf8
<span class="token keyword">NATIONAL</span> <span class="token keyword">CHARACTER</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span>
<span class="token datatype">NCHAR</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span></code></pre>
  </div>
  <p>
   As are these:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa52624511"><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 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> utf8
<span class="token keyword">NATIONAL</span> <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 datatype">NVARCHAR</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span>
<span class="token datatype">NCHAR</span> <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">NATIONAL</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">VARYING</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span>
<span class="token keyword">NATIONAL</span> <span class="token datatype">CHAR</span> <span class="token keyword">VARYING</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span></code></pre>
  </div>
  <p>
   You can use
   <code class="literal">
    N'
    <em class="replaceable">
     <code>
      literal
     </code>
    </em>
    '
   </code>
   (or
   <code class="literal">
    n'
    <em class="replaceable">
     <code>
      literal
     </code>
    </em>
    '
   </code>
   ) to
        create a string in the national character set. These statements
        are equivalent:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa61123835"><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">SELECT</span> N<span class="token string">'some text'</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> n<span class="token string">'some text'</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> _utf8<span class="token string">'some text'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   MySQL 8.4 interprets the national character set as
   <code class="literal">
    utf8mb3
   </code>
   , which is now deprecated. Thus, using
   <code class="literal">
    NATIONAL CHARACTER
   </code>
   or one of its synonyms to
        define the character set for a database, table, or column raises
        a warning similar to this one:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa77296006"><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">NATIONAL</span><span class="token operator">/</span><span class="token datatype">NCHAR</span><span class="token operator">/</span><span class="token datatype">NVARCHAR</span> implies the <span class="token keyword">character</span> <span class="token keyword">set</span> UTF8MB3<span class="token punctuation">,</span> which will be
replaced <span class="token keyword">by</span> UTF8MB4 <span class="token keyword">in</span> a future <span class="token keyword">release</span><span class="token punctuation">.</span> Please consider <span class="token keyword">using</span> <span class="token datatype">CHAR</span><span class="token punctuation">(</span>x<span class="token punctuation">)</span> <span class="token keyword">CHARACTER</span>
<span class="token keyword">SET</span> UTF8MB4 <span class="token keyword">in</span> <span class="token keyword">order</span> <span class="token keyword">to</span> be unambiguous<span class="token punctuation">.</span></code></pre>
  </div>
 </div>
 <br/>
</div>
