Oracle 5.0 Reference Manual page 871

Table of Contents

Advertisement

pad bytes will result in a duplicate-key error. For example, if a table contains 'a', an attempt to store
causes a duplicate-key error.
'a\0'
You should consider the preceding padding and stripping characteristics carefully if you plan to use the
data type for storing binary data and you require that the value retrieved be exactly the same
BINARY
as the value stored. The following example illustrates how 0x00-padding of
column value comparisons:
mysql>
CREATE TABLE t (c BINARY(3));
Query OK, 0 rows affected (0.01 sec)
mysql>
INSERT INTO t SET c = 'a';
Query OK, 1 row affected (0.01 sec)
mysql>
SELECT HEX(c), c = 'a', c = 'a\0\0' from t;
+--------+---------+-------------+
| HEX(c) | c = 'a' | c = 'a\0\0' |
+--------+---------+-------------+
| 610000 |
+--------+---------+-------------+
1 row in set (0.09 sec)
If the value retrieved must be the same as the value specified for storage with no padding, it might be
preferable to use
11.1.6.3. The
BLOB
A
is a binary large object that can hold a variable amount of data. The four
BLOB
TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB. These differ only in the maximum length of the
values they can hold. The four
correspond to the four
See
Section 11.2, "Data Type Storage
values are treated as binary strings (byte strings). They have no character set, and sorting and
BLOB
comparison are based on the numeric values of the bytes in column values.
nonbinary strings (character strings). They have a character set, and values are sorted and compared
based on the collation of the character set.
If strict SQL mode is not enabled and you assign a value to a
column's maximum length, the value is truncated to fit and a warning is generated. For truncation of
nonspace characters, you can cause an error to occur (rather than a warning) and suppress insertion
of the value by using strict SQL mode. See
Beginning with MySQL 5.0.60, truncation of excess trailing spaces from values to be inserted into
columns always generates a warning, regardless of the SQL mode.
For
and
TEXT
If a
column is indexed, index entry comparisons are space-padded at the end. This means that, if
TEXT
the index requires unique values, duplicate-key errors will occur for values that differ only in the number
of trailing spaces. For example, if a table contains 'a', an attempt to store
key error. This is not true for
In most respects, you can regard a
you like. Similarly, you can regard a
VARBINARY
• There is no trailing-space removal for
Before MySQL 5.0.3, this differs from
removed when values are stored.
On comparisons,
VARCHAR.
0 |
1 |
or one of the
VARBINARY
and
Types
TEXT
TEXT
types and have the same maximum lengths and storage requirements.
BLOB
columns, there is no padding on insert and no bytes are stripped on select.
BLOB
columns.
BLOB
BLOB
and
in the following ways:
VARCHAR
is space extended to fit the compared object, exactly like
TEXT
String Types
data types instead.
BLOB
types are TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT. These
Requirements".
Section 5.1.7, "Server SQL
column as a
VARBINARY
column as a
TEXT
VARCHAR
and
columns when values are stored or retrieved.
BLOB
TEXT
and VARCHAR, for which trailing spaces are
VARBINARY
851
BINARY
BLOB
values are treated as
TEXT
or
column that exceeds the
BLOB
TEXT
Modes".
causes a duplicate-
'a '
column that can be as large as
column.
and
BLOB
TEXT
CHAR
values affects
types are
TEXT
differ from
and

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents