binary
This page is part of MariaDB's Documentation.
The parent of this page is: Character Sets for MariaDB Xpand
Topics on this page:
Overview
Binary pseudo charset (maxlen 1)
DETAILS
Default Collation: binary
Max Length: 1 bytes
The collation names accepted for this character set are:
EXAMPLES
SELECT TYPEOF(_binary'Test') AS result1,
TYPEOF(CONVERT('Test' USING binary)) AS result2\G
*************************** 1. row ***************************
result1: varbinary(255) not null
result2: varbinary(65535)
CREATE TABLE charset_example (
name VARCHAR(32),
description VARCHAR(64) CHARSET binary
);
SET NAMES utf8;
SET @txt = _utf8"Dji pou magnî do vêre, çoula m' freut nén må.";
INSERT INTO charset_example VALUES
('test 1', CONVERT(@txt USING binary)),
('test 2', 'A normal string.');
SELECT name,
LENGTH(description) AS bytes,
CHAR_LENGTH(description) AS chars
FROM charset_example;
+--------+-------+-------+
| name | bytes | chars |
+--------+-------+-------+
| test 1 | 50 | 50 |
| test 2 | 16 | 16 |
+--------+-------+-------+
SET SESSION character_set_connection = 'binary';