Home > Database > Mysql Tutorial > What does char mean in mysql?

What does char mean in mysql?

王林
Release: 2020-06-24 16:07:35
Original
8911 people have browsed it

Char in mysql represents a fixed-length string type. Its characteristics are: 1. The storage space is fixed; 2. When the length is not enough, the internal storage is filled with spaces; 3. After the input character length exceeds the specified length, char will intercept excess characters. The char type is suitable for storing very short strings.

What does char mean in mysql?

(Recommended tutorial: mysql tutorial)

char

char: fixed-length string Type

Features:

  • Fixed storage space.

  • When the length is not enough, the internal storage is filled with spaces.

  • If there are spaces at the end of the field itself, the search will automatically truncate the spaces at the end (because it is not clear whether the spaces are contained in the field or generated by padding).

  • If there are spaces at the front of the field itself, it will not be truncated.

  • When the input character length exceeds the specified length, char will intercept the excess characters.

For example: When a field type is defined as char(10) and the inserted value is the string "abc", they occupy the same 10 bytes of space, because The remaining 7 positions are filled with spaces.

Applicable situations:

  • Suitable for storing very short strings or strings close to the same length.

  • char is more efficient in access than varchar because it is a fixed length.

  • For very short columns, char is also more efficient in storage space than varchar.

The above is the detailed content of What does char mean in mysql?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template