BLOB data type
This page documents the preview version (v2.23). Preview includes features under active development and is for development and testing only. For production, use the stable version (v2024.1). To learn more, see Versioning.
Synopsis
Use the BLOB data type to represent arbitrary binary data of variable length.
Syntax
type_specification ::= BLOB
blob_literal ::= "0x" [ hex_digit hex_digit ...]
Where
hex_digitis a hexadecimal digit ([0-9a-fA-F]).
Semantics
- Columns of type
BLOBcan be part of thePRIMARY KEY. - Implicitly,
BLOBdata type is neither convertible nor comparable with other data types. - Two series of builtin-functions
BlobAs<Type>and<Type>AsBlobare provided for conversion betweenBLOBand other data types. BLOBsize is virtually unlimited.
Examples
ycqlsh:example> CREATE TABLE messages(id INT PRIMARY KEY, content BLOB);
ycqlsh:example> INSERT INTO messages (id, content) VALUES (1, 0xab00ff);
ycqlsh:example> INSERT INTO messages (id, content) VALUES (2, 0x);
ycqlsh:example> UPDATE messages SET content = 0x0f0f WHERE id = 2;
ycqlsh:example> SELECT * FROM messages;
id | content
----+----------
2 | 0x0f0f
1 | 0xab00ff