Create a roaring bitmap column
seekdb allows you to create a roaring bitmap column by using the CREATE TABLE or ALTER TABLE statement.
Considerations
- To view the query results in a visualized format, you need to add the
--binary-as-hexparameter when connecting to the client to convert binary results to hexadecimal.
Examples
Use the CREATE TABLE statement to create a table with a roaring bitmap column. Here is the syntax:
CREATE TABLE t1 (rb ROARINGBITMAP);
Use the ALTER TABLE statement to add or drop a roaring bitmap column from an existing table. Here is the syntax:
ALTER TABLE t1 ADD COLUMN rb2 ROARINGBITMAP;
ALTER TABLE t1 DROP COLUMN rb2;
Set the default value for a roaring bitmap column. Here is the syntax:
ALTER TABLE t1 MODIFY COLUMN rb ROARINGBITMAP DEFAULT x'0100';
Here are examples of writing and querying roaring bitmap data:
// Create a test table.
CREATE TABLE t2 (
rb ROARINGBITMAP
);
DESC t2;
// Insert test data.
INSERT INTO t2 VALUES (rb_from_string('1,2,3'));
INSERT INTO t2 VALUES (x'0100');
// Query the test table.
SELECT * FROM t2;
The returned result is as follows:
+----------------------------------+
| rb |
+----------------------------------+
| 0x010303010000000200000003000000 |
| 0x0100 |
+----------------------------------+
2 rows in set (0.002 sec)