Home > Database > Mysql Tutorial > Does MySQL's INT(11) Column Really Use 11 Bytes of Storage?

Does MySQL's INT(11) Column Really Use 11 Bytes of Storage?

Linda Hamilton
Release: 2024-12-28 16:05:10
Original
789 people have browsed it

Does MySQL's INT(11) Column Really Use 11 Bytes of Storage?

Storage Size and Range of INT(11) Column in MySQL

The storage size of a column of type INT(11) in MySQL is consistently 4 bytes, regardless of the length specified. This information is crucial when designing database schemas to meet specific storage requirements.

MySQL supports several integer data types, including:

  • TINYINT: 1 byte (8-bit)
  • SMALLINT: 2 bytes (16-bit)
  • MEDIUMINT: 3 bytes (24-bit)
  • INT: 4 bytes (32-bit)
  • BIGINT: 8 bytes (64-bit)

The length parameter in INT(11) is used to specify how many characters should be padded when selecting data from the database. However, it does not affect the actual storage size of the numeric value.

For example, storing the value 12345 in an INT(3) column will still result in the same 4-byte storage size. However, when selecting data with the MySQL command line client, it will be displayed with three leading zeros (e.g., 00012345) to match the specified length.

The maximum value that can be stored in an INT(11) column is 2,147,483,647 for signed integers and 4,294,967,295 for unsigned integers. These values align with the signed and unsigned limits for 32-bit integers, which represent the underlying storage type.

The above is the detailed content of Does MySQL's INT(11) Column Really Use 11 Bytes of Storage?. For more information, please follow other related articles on the PHP Chinese website!

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 Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template