OceanBase AI Database supports creating highly compressed bitmap columns using the CREATE TABLE or ALTER TABLE statement.
Considerations
- To view the query results visually, add the
--binary-as-hexparameter when connecting to the client to convert the binary results into hexadecimal.
Examples
You can execute the CREATE TABLE statement to create a table with highly compressed bitmap columns. Syntax example:
CREATE TABLE t1 (rb ROARINGBITMAP);
You can use the ALTER TABLE statement to add or drop highly compressed bitmap columns in an existing table. Syntax example:
ALTER TABLE t1 ADD COLUMN rb2 ROARINGBITMAP;
ALTER TABLE t1 DROP COLUMN rb2;
To efficiently set a default value for a bitmap column, use the following syntax:
ALTER TABLE t1 MODIFY COLUMN rb ROARINGBITMAP DEFAULT x'0100';
The following example shows how to efficiently write and query compressed bitmap data:
// Create a test table.
obclient> CREATE TABLE t2 (
rb ROARINGBITMAP
);
DESC t2;
// Insert test data
obclient> INSERT INTO t2 VALUES (rb_from_string('1,2,3'));
INSERT INTO t2 VALUES (x'0100');
// Query the test table.
obclient> SELECT * FROM t2;
The return result is as follows:
+----------------------------------+
| rb |
+----------------------------------+
| 0x010303010000000200000003000000 |
| 0x0100 |
+----------------------------------+
2 rows in set