Programming learning: MYSQL database coding principle

There are two concepts in the mysql coding plane, which everyone does not need to know. One is the character code "character set" and the check code "collations". Let's talk about these two things below.

1. What is the character set "character set"

Databases have character sets. Character sets are a very big concept. Character sets specify the encoding of different characters. A character set is a set of symbols and encodings.

For example, the "ASCII character set" we often say is a set of conforming numbers including numbers, uppercase and lowercase letters, semicolons, line breaks, etc. The encoding method is sorted according to certain rules and requirements.

For example, the code of letter A is 65. ASCII only specifies the encoding of English letters, not because letters (such as Chinese characters) are represented by ASCII encoding.

Because of this, every country will encode its own language, and our country is the GB2312 encoding. If your website needs to use multiple languages, use utf8 encoding, because utf8 encoding is an international universal encoding.

utf8 encoding encodes all languages ​​in the world. For these codes, there is a concept of inclusion, such as GB2312 encoding contains ASCII characters,

UTF8 encoding contains GB2312 characters and ASCII characters. If the website is to use multiple languages, the most appropriate is to use utf8 encoding.

When we use text storage, encoding issues are involved everywhere. Our commonly used mysql database supports multiple character sets,

In addition, it supports conversion between different character sets, which facilitates the direct migration of different character sets and supports multiple languages. We must pay attention when migrating (migrating) the mysql database.

Otherwise, database garbled problems will occur. There are some commonly used terms about this, you should know:

Characters: Chinese characters, English letters, punctuation marks, Latin, etc.

Encoding: change the character into a computer-stored format, such as ASCII, change the letter A to 65 for storage.

Character set: a group of characters and the corresponding encoding method.

2. What is collation "collations"

"Collations" means "check". This verification code is used in the mysql database, and its role is to guide mysql to compare and organize characters.

In the process of web page development, you can basically ignore the collations check, we just use the default check code in the database.

 


In addition, if you want to better improve your programming ability, learn C language and C++ programming! Overtaking in a curve, one step faster! I may be able to help you here~

UP has uploaded some video tutorials on learning C/C++ programming on the homepage. Those who are interested or are learning must go and take a look! It will be helpful to you~

Sharing (source code, actual project video, project notes, basic introductory tutorial)

Welcome partners who change careers and learn programming, use more information to learn and grow faster than thinking about it yourself!

Programming learning:

Programming learning:

Guess you like

Origin blog.csdn.net/weixin_45713725/article/details/115215797