In Cassandra, Blob data type represents constant hexadecimal data type and the number is defined as 0[xX](hex)+ where hex means hexadecimal. It is useful to store a short string or small images.
In this article we will discuss Blob conversion function which converts the native types into binary data (blob):
typeAsBlob(value) blobAsType(value)
Let’s understand with an example.
To create table function_test1 used the following CQL query.
CREATE TABLE function_test1 ( Name varchar PRIMARY KEY, type_value blob );
To insert data into the table using the following CQL query.
INSERT INTO function_test1 (Name, type_value)
VALUES ('Ashish', bigintAsBlob(5));
INSERT INTO function_test1 (Name, type_value)
VALUES ('Rana', bigintAsBlob(9));
To read the data using the following CQL query.
SELECT * FROM function_test1;
Output:

Now, to convert blobAsBigint then first update the table by using the following CQL query.
ALTER TABLE function_test1 ADD Id bigint;
Now, again insert data into the updated table. So, let’s have a look.
INSERT INTO function_test1 (Name, Id)
VALUES ('Ashish', blobAsBigint(0x0000000000000005));
INSERT INTO function_test1 (Name, Id)
VALUES ('Rana', blobAsBigint(0x0000000000000009));
To see the final output used the following CQL query.
SELECT * FROM function_test1;
Output:

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
Recommended Posts:
- CAST function in Cassandra
- Partitioners with the TOKEN function in Cassandra
- User Defined Function in Cassandra
- Static type using batch in Cassandra
- Role of keys in Cassandra
- High Availability Mechanism in Cassandra
- Apache Cassandra tools
- Designing models in Cassandra
- Introduction to Apache Cassandra
- Apache Cassandra (NOSQL database)
- Architecture of Apache Cassandra
- Overview of User Defined Type (UDT) in Cassandra
- Overview of Data modeling in Apache Cassandra
- Concept of indexing in Apache Cassandra
- Collection Data Type in Apache Cassandra
- Pre-defined data type in Apache Cassandra
- Monitoring cluster in Cassandra
- Virtual machine installation for Cassandra CQL query
- Data Manipulation in Cassandra
- Aggregate functions in Cassandra
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

