MySQL Equivalent of PostgreSQL C Collation

collationMySQL

I'm working on reimplementing a Postgres schema in MySQL, and one of the things I can't seem to find a clear equivalent for is Postgres' "C" collation.

id TEXT COLLATE "C" NOT NULL

What would be the equivalent collation for MySQL?

Best Answer

C is PostgreSQL's way of saying do not reinterpret the data, order it according to binary byte comparisons. From the docs

On all platforms, the collations named default, C, and POSIX are available. Additional collations may be available depending on operating system support. The default collation selects the LC_COLLATE and LC_CTYPE values specified at database creation time. The C and POSIX collations both specify “traditional C” behavior, in which only the ASCII letters “A” through “Z” are treated as letters, and sorting is done strictly by character code byte values.

MySQL seems to call it binary the "Binary pseudo charset". Whether or not they're optimized to take advantage of that is another question.

See also