What Are the Differences between CHAR and NCHAR

Q

What Are the Differences between CHAR and NCHAR? - MySQL FAQs - Introduction to SQL Basics

✍: FYIcenter.com

A

Both CHAR and NCHAR are fixed length string data types. But they have the following differences:

  • CHAR's full name is CHARACTER.
  • NCHAR's full name is NATIONAL CHARACTER.
  • By default, CHAR uses ASCII character set. So 1 character is always stored as 1 byte.
  • By default, NCHAR uses Unicode character set. NCHAR data are stored in UTF8 format. So 1 character could be stored as 1 byte or upto 4 bytes.
  • Both CHAR and NCHAR columns are defined with fixed lengths in units of characters.

The following column definitions are the same:

CREATE TABLE faq (Title NCHAR(80));
CREATE TABLE faq (Title NATIONAL CHAR(80));
CREATE TABLE faq (Title NATIONAL CHARACTER(80));
CREATE TABLE faq (Title CHAR(80) CHARACTER SET utf8);
CREATE TABLE faq (Title CHARACTER(80) CHARACTER SET utf8);

2007-05-11, 4890👍, 0💬