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

What does char mean in mysql?

王林
王林Original
2020-06-24 16:07:358875browse

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!

Statement:
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

Related articles

See more