Home > Database > Mysql Tutorial > What is the use of NCHAR in MySQL?

What is the use of NCHAR in MySQL?

PHPz
Release: 2023-09-11 15:09:03
forward
1793 people have browsed it

What is the use of NCHAR in MySQL?

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.

Example

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)
Copy after login

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template