I have a long list of indexes/numbers from 0 to 10 million
. I would like to mark each of these numbers as true/false or set/unset
. I want to avoid creating a table with a row for everynumber like
CREATE TABLE foo (number integer, set boolean)
Instead, I was thinking that I could do some bitwise computation to store and retrive this data from a single cell. Can I use the Bit(N)
data type here?
CREATE TABLE some_table (my_store BIT(1000000)) // 1 million
How should I go about setting/unsetting/retriving a bit value at a particular position?
EDIT
I found that BIT(10000000)
gives an error is out of range for type integer
.
set
and how manyunset
?int
size for this column. So if you just store the ones that areset
, then you would have a table sized under 300MB, which isn't that big. A columnstore index would compress this down to a few KB.