Home  >  Article  >  Database  >  What is the difference between database char and varchar?

What is the difference between database char and varchar?

coldplay.xixi
coldplay.xixiOriginal
2020-07-24 15:29:1617031browse

The difference between database char and varchar: 1. The length of the char type is fixed, while the length of the varchar type is variable; 2. The data length of the char type is the same each time it is modified, and the efficiency is higher. The data length of the varchar type is different each time it is modified, and the efficiency is lower.

What is the difference between database char and varchar?

The difference between database char and varchar:

1. Different lengths

1. Char type: The length of char type is fixed.

2. Varchar type: The length of varchar type is variable.

2. Different efficiencies

1. Char type: The data length of the char type is the same each time it is modified, and the efficiency is higher.

2. Varchar type: The data length of the varchar type is different each time it is modified, and the efficiency is lower.

What is the difference between database char and varchar?

3. Different storage

1. Char type: When the char type is stored, it is the initial expected string plus a Record the length of the string in bytes, which takes up a lot of space.

2. Varchar type: The varchar type stores the actual string plus a byte recording the length of the string, which takes up less space.

Related learning recommendations: mysql video tutorial

The above is the detailed content of What is the difference between database char and varchar?. 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