BLOB Type

AttentionThis page documents an earlier version. Go to the latest (v2.1)version.

Synopsis

BLOB datatype is used to represent arbitrary binary data of variable length.

Syntax

  1. type_specification ::= BLOB
  2. blob_literal ::= "0x" [ hex_digit hex_digit ...]

Where

  • hex_digit is a hexadecimal digit ([0-9a-fA-F]).

Semantics

  • Columns of type BLOB can be part of the PRIMARY KEY.
  • Implicitly, BLOB datayype is neither convertible nor comparable with other datatypes.
  • Two series of builtin-functions BlobAs<Type> and <Type>AsBlob are provided for conversion between BLOB and other datatypes.
  • BLOB size is virtually unlimited.

Examples

You can do this as shown below.

  1. cqlsh:example> CREATE TABLE messages(id INT PRIMARY KEY, content BLOB);
  1. cqlsh:example> INSERT INTO messages (id, content) VALUES (1, 0xab00ff);
  1. cqlsh:example> INSERT INTO messages (id, content) VALUES (2, 0x);
  1. cqlsh:example> UPDATE messages SET content = 0x0f0f WHERE id = 2;
  1. cqlsh:example> SELECT * FROM messages;
  1. id | content
  2. ----+----------
  3. 2 | 0x0f0f
  4. 1 | 0xab00ff

See Also

Data Types