Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set character set in Mysql

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article will explain in detail how to set the character set in Mysql. The content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.

# #

DROP TABLE test_var

CREATE TABLE test_var (NAME VARCHAR (5)) CHARACTER SET utf8

INSERT INTO test_var (NAME) VALUES ('have you along the way');-- successful

INSERT INTO test_var (NAME) VALUES ('have you along the way');-- Data too LONG FOR COLUMN 'name' AT ROW 1

INSERT INTO test_var (NAME) VALUES (',');-successful

INSERT INTO test_var (NAME) VALUES (', 6 symbols failed

SELECT * FROM test_var

# #

Of course, all the premise is that the character set is set correctly before the correct insert.

When creating the table, because the character set utf8 is not specified, the default character set latin1 of the database is used. The character set of my client is utf8.

In the client- > connection- > server character set conversion, that is, utf8- > latin1- > latin1 conversion, there is garbled in the first conversion, so garbled error is reported in insert.

# #

Since the utf8 character set is used in the background and front end, it is recommended that the database also use the utf8 character set.

To do this, we need to modify the default character set of the database.

>

The concept of character set

Basic concept

The @ character (Character) refers to the smallest semantic symbol in human language. For example,'A','B', etc.

Given a series of characters, each character is assigned a numeric value, which is represented by a numeric value, which is the Encoding of the character. For example, if we assign a value of 0 to the character'A' and a value of 1 to the character'B', then 0 is the encoding of the character'A'.

Given a series of characters and given the corresponding encoding, the set of all these characters and coding pairs is the character set (Character Set). For example, if the list of characters given is {'Aggregano'}, {'A'= > 0, 'Bai = > 1} is a character set.

The @ character order (Collation) refers to the comparison rules between characters in the same character set.

@ determine the character order before you can define what are equivalent characters and the size relationship between characters on a character set

@ each character order uniquely corresponds to one character set, but a character set can correspond to multiple character orders, one of which is the default character order (Default Collation)

The character order names in @ MySQL follow the naming convention: they start with the character set name corresponding to the character order, and end with _ ci (for case insensitivity), _ cs (for case sensitivity), or _ bin (for comparison by coded value). For example, under the character order "utf8_general_ci", the characters "a" and "A" are equivalent.

On how to set the character set in Mysql to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report