Oracle 5.0 Reference Manual page 870

Table of Contents

Advertisement

of trailing pad characters will result in a duplicate-key error. For example, if a table contains 'a', an
attempt to store
11.1.6.2. The
BINARY
The
BINARY
strings rather than nonbinary strings. That is, they contain byte strings rather than character strings.
This means that they have no character set, and sorting and comparison are based on the numeric
values of the bytes in the values.
The permissible maximum length is the same for
VARCHAR, except that the length for
characters.
The
BINARY
data types. For the latter types, the
binary string column. Instead, it causes the binary collation for the column character set to be used,
and the column itself contains nonbinary character strings rather than binary byte strings. For example,
CHAR(5) BINARY
assuming that the default character set is latin1. This differs from BINARY(5), which stores 5-
bytes binary strings that have no character set or collation. For information about differences between
nonbinary string binary collations and binary strings, see
Collations".
If strict SQL mode is not enabled and you assign a value to a
exceeds the column's maximum length, the value is truncated to fit and a warning is generated. For
cases of truncation, you can cause an error to occur (rather than a warning) and suppress insertion of
the value by using strict SQL mode. See
When
BINARY
pad value and how it is handled is version specific:
• As of MySQL 5.0.15, the pad value is
insert, and no trailing bytes are removed on select. All bytes are significant in comparisons, including
ORDER BY
< space.
0x00
Example: For a
when inserted. Both inserted values remain unchanged when selected.
\0\0'
• Before MySQL 5.0.15, the pad value is space. Values are right-padded with space on insert, and
trailing spaces are removed on select. Trailing spaces are ignored in comparisons, including
and
BY
DISTINCT
space.
Example: For a
becomes
'a\0'
For VARBINARY, there is no padding on insert and no bytes are stripped on select. All bytes are
significant in comparisons, including
are different in comparisons, with
removed when values are stored. Before MySQL 5.0.15, trailing 0x00 bytes are removed for
operations.)
Note: The
InnoDB
column values through MySQL 5.0.18. Beginning with MySQL 5.0.19,
characters in making comparisons as do other MySQL storage engines.
For those cases where trailing pad bytes are stripped or comparisons ignore them, if a column has an
index that requires unique values, inserting into the column values that differ only in number of trailing
causes a duplicate-key error.
'a '
and
VARBINARY
and
types are similar to
VARBINARY
and
data types are distinct from the
VARBINARY
BINARY
is treated as
CHAR(5) CHARACTER SET latin1 COLLATE
values are stored, they are right-padded with the pad value to the specified length. The
and
operations.
DISTINCT
column,
BINARY(3)
operations.
0x00
column,
BINARY(3)
when inserted and
'a\0 '
0x00
storage engine continues to preserve trailing spaces in
String Types
Types
and VARCHAR, except that they contain binary
CHAR
and
BINARY
and
BINARY
VARBINARY
attribute does not cause the column to be treated as a
Section 10.1.7.6, "The
Section 5.1.7, "Server SQL
(the zero byte). Values are right-padded with
0x00
bytes and spaces are different in comparisons, with
0x00
becomes
'a '
'a \0'
bytes and spaces are different in comparisons, with
becomes
'a '
'a
when selected.
'a\0'
and
ORDER BY
DISTINCT
< space. (Exceptions: Before MySQL 5.0.3, trailing spaces are
850
as it is for
VARBINARY
is a length in bytes rather than in
and
CHAR BINARY
VARCHAR BINARY
latin1_bin,
_bin
or
BINARY
VARBINARY
Modes".
when inserted.
'a\0'
when inserted and
'
'a'
operations.
bytes and spaces
0x00
BINARY
uses trailing space
InnoDB
and
CHAR
and
binary
column that
on
0x00
becomes
'a
ORDER
<
0x00
when selected.
ORDER BY
and
VARBINARY

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents