CreatetableStudent1(NameChar(10)charactersetutf8,AddressNATIONALCHARACTER(10),FatherNameNCHAR(10));"/> CreatetableStudent1(NameChar(10)charactersetutf8,AddressNATIONALCHARACTER(10),FatherNameNCHAR(10));">
MySQL defines NCHAR as a way to indicate that a CHAR column should use a predefined character set. MySQL uses Utf8 as its predefined character set.
In the following example, we will create a table named "Student1". In this table, we declare the data types of three columns using three different declaration styles that are equivalent to each other. All thanks to NCHAR.
mysql> Create table Student1(Name Char(10) character set utf8, Address NATIONAL CHARACTER(10), FatherName NCHAR(10)); Query OK, 0 rows affected (0.25 sec)
Now check the status of the table, with the help of the following query we can see that all the declaration styles are the same.
mysql> show create table Student1\G *************************** 1. row *************************** Table: Student1 Create Table: CREATE TABLE `student1` ( `Name` char(10) CHARACTER SET utf8 DEFAULT NULL, `Address` char(10) CHARACTER SET utf8 DEFAULT NULL, `FatherName` char(10) CHARACTER SET utf8 DEFAULT NULL ) ENGINE = InnoDB DEFAULT CHARSET = latin1 1 row in set (0.00 sec)
The above is the detailed content of What is the use of NCHAR in MySQL?. For more information, please follow other related articles on the PHP Chinese website!