Skip to content

VARBINARY

CREATE TABLE VarbinaryTest (
id INT AUTO_INCREMENT,
data VARBINARY(10),
PRIMARY KEY (id)
);
INSERT INTO VarbinaryTest (data)
VALUES (0x5468697320495320412054657374);
SELECT * FROM VarbinaryTest;
iddata
10x5468697320495320412054657374

In this example, a VARBINARY column data is created and then populated with a hex value. When this value is later retrieved, it is shown in its binary form. The VARBINARY type stores binary data as a variable-length string, up to a maximum length that is specified in parentheses. It is useful for holding non-character data such as images or other types of binary files.