Oracle 5.0 Reference Manual page 880

Table of Contents

Advertisement

Data Type
YEAR
For details about internal representation of temporal values, see
Algorithms and
Storage Requirements for String Types
In the following table,
and bytes for binary string types.
Data Type
CHAR(M)
BINARY(M)
VARCHAR(M),
TINYBLOB,
BLOB,
TEXT
MEDIUMBLOB,
LONGBLOB,
ENUM('value1','value2',...)
SET('value1','value2',...)
Variable-length string types are stored using a length prefix plus data. The length prefix requires from
one to four bytes depending on the data type, and the value of the prefix is
string). For example, storage for a
bytes to store the length of the value.
To calculate the number of bytes used to store a particular CHAR, VARCHAR, or
must take into account the character set used for that column and whether the value contains multi-
byte characters. In particular, when using the
not all characters use the same number of bytes and can require up to three bytes per character. For
a breakdown of the storage used for different categories of
"Unicode
Support".
VARCHAR, VARBINARY, and the
requirements depend on these factors:
• The actual length of the column value
• The column's maximum possible length
• The character set used for the column, because some character sets contain multi-byte characters
For example, a
Assuming that the column uses the
required is the length of the string (L), plus one byte to record the length of the string. For the string
is 4 and the storage requirement is five bytes. If the same column is instead declared to use
'abcd',
L
the
double-byte character set, the storage requirement is 10 bytes: The length of
ucs2
bytes and the column requires two bytes to store lengths because the maximum length is greater than
255 (up to 510 bytes).
Storage Requirements for String Types
Structures.
represents the declared column length in characters for nonbinary string types
M
L
VARBINARY(M)
TINYTEXT
MEDIUMTEXT
LONGTEXT
MEDIUMTEXT
BLOB
column can hold a string with a maximum length of 255 characters.
VARCHAR(255)
Storage Required
1 byte
represents the actual length in bytes of a given string value.
Storage Required
×
bytes, 0
M
w
<= M <=
required for the maximum-length character in the character
set
bytes, 0
M
<= M <=
+ 1 bytes if column values require 0 – 255 bytes,
L
bytes if values may require more than 255 bytes
+ 1 bytes, where
L
+ 2 bytes, where
L
+ 3 bytes, where
L
+ 4 bytes, where
L
1 or 2 bytes, depending on the number of enumeration
values (65,535 values maximum)
1, 2, 3, 4, or 8 bytes, depending on the number of set
members (64 members maximum)
value requires
Unicode character set, you must keep in mind that
utf8
and
types are variable-length types. For each, the storage
TEXT
character set (one byte per character), the actual storage
latin1
860
MySQL Internals: Important
255, where
is the number of bytes
w
255
8
< 2
L
16
< 2
L
24
< 2
L
32
< 2
L
(the byte length of the
L
bytes to store the value plus three
L
TEXT
characters, see
Section 10.1.10,
utf8
+ 2
L
column value, you
is eight
'abcd'

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents