Knowledgebase

Character Sets and Collations Print

  • 0

Storing text correctly.

WHAT A CHARACTER SET IS

The set of characters that can be stored, and how they are encoded.

WHAT A COLLATION IS

The rules for comparing and sorting them.

WHAT TO USE

A full modern encoding supporting every character, including symbols outside the basic range.

WHY THE DISTINCTION MATTERS IN MYSQL

An older encoding named as if it were complete stores only part of the range.

WHAT THAT BREAKS

Characters outside the basic range, which are silently rejected or truncate the value.

WHAT TO USE INSTEAD

The four-byte variant.

WHERE THE SETTING APPLIES

The server The database The table The column The connection

WHY THE CONNECTION MATTERS MOST

Correct storage with a wrong connection setting corrupts on the way in or out.

WHAT CORRUPTION LOOKS LIKE

Accented and non-Latin characters appearing as nonsense.

WHY IT IS FREQUENTLY PERMANENT

Once stored wrongly, the original bytes are gone.

WHAT TO CHECK ON ANY MIGRATION

That the dump, the import and the connection all agree.

WHAT COLLATION AFFECTS

Whether comparisons are case-sensitive Sort order Which values are considered equal

WHY THAT CAN SURPRISE

Two visually different strings may compare as equal.

WHAT TO KEEP CONSISTENT

Collation across columns that are joined.

WHY

Mismatched collations prevent index use on the join.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot