MySQL Data Methods | 3
MySQL Data Methods
Properties of Binary and Non-Binary Strings
String values fall into two general categories, binary and non-binary:
|
Character units vary in their storage requirements. A single-byte character set such as
latin1 uses one byte per character, but there also are multi-byte character sets in which
some or all characters require more than one byte. For example, both of the Unicode
character sets available in MySQL are multi-byte. ucs2 is a double-byte character set in
which each character requires two bytes. utf8 is a variable-length multi-byte character
set with characters that take from one to three bytes.
To find out which character sets and collations are available in your server as it currently is configured, use these two statements:

As shown by the output from SHOW COLLATION, each collation is specific to a given character
set, but a given character set might have several collations. Collation names usually
consist of a character set name, a language, and an additional suffix. For example,
utf8_icelandic_ci is a collation for the utf8 Unicode character set in which comparisons
follow Icelandic sorting rules and characters are compared in case-insensitive fashion.
Collation suffixes have the following meanings:
|
The sorting properties for binary and non-binary strings differ as follows:
|
Because collations are used for comparison and sorting, they affect many operations:
|
To determine the character set or collation of a string, you can use the CHARSET() and
COLLATION() functions.
Quoted string literals are interpreted according to the current server settings.The
default character set and collation are latin1 and latin1_swedish_ci:

MySQL treats hexadecimal constants as binary strings by default:

Created: March 27, 2003
Revised: April 24, 2006
URL: http://webreference.com/programming/mysql_data/1


