Dimensioni dei Tipi di Dati
Le seguenti tabelle indicano approssimativamente lo spazio occupato da ogni tipo di dato.
Tipi numerici
Tipo | Spazio occupato |
---|---|
TINYINT | 1 byte |
SMALLINT | 2 byte |
MEDIUMINT | 3 byte |
INT | 4 byte |
BIGINT | 8 byte |
FLOAT(p) | 4 byte se p <= 24, altrimenti 8 byte |
DOUBLE | 8 byte |
DECIMAL | Vedi tabella sotto |
BIT(M) | (M+7)/8 byte |
Decimali
I Decimali sono registrati in formato binario, con la parte intera e quella frazionale registrate separatamente. Per ogni nove cifre occorrono 4 byte, seguiti da un certo numero di byte per ciò che rimane, come segue:
Cifre rimanenti | Spazio occupato |
---|---|
0 | 0 byte |
1 | 1 byte |
2 | 1 byte |
3 | 2 byte |
4 | 2 byte |
5 | 3 byte |
6 | 3 byte |
7 | 4 byte |
8 | 4 byte |
String data types
In the descriptions below, M
is the declared column length (in characters or in bytes), while len
is the actual length in bytes of the value.
Data Type | Storage Requirement |
---|---|
ENUM | 1 byte for up to 255 enum values, 2 bytes for 256 to 65,535 enum values |
CHAR(M) | M × w bytes, where w is the number of bytes required for the maximum-length character in the character set |
BINARY(M) | M bytes |
VARCHAR(M), VARBINARY(M) | len + 1 bytes if column is 0 – 255 bytes, len + 2 bytes if column may require more than 255 bytes |
TINYBLOB, TINYTEXT | len + 1 bytes |
BLOB, TEXT | len + 2 bytes |
MEDIUMBLOB, MEDIUMTEXT | len + 3 bytes |
LONGBLOB, LONGTEXT | len + 4 bytes |
SET | Given M members of the set, (M+7)/8 bytes, rounded up to 1, 2, 3, 4, or 8 bytes |
In some character sets, not all characters use the same number of bytes. utf8 encodes characters with one to three bytes per character, while utf8mb4 requires one to four bytes per character.
Date and time data types
Commenti
Sto caricando i commenti......
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.