2 ms·
Like Oracle, SQLite lacks boolean (bit) columns, but it does support bitwise operators, so multiple boolean values can be packed into an integer with powers of
by chasil 4y ago
Like Oracle, SQLite lacks boolean (bit) columns, but it does support bitwise operators, so multiple boolean values can be packed into an integer with powers of 2.
Setting a value with an update is a bitwise or, and checking a value is a bitwise and.
$ sqlite3
SQLite version 3.36.0 2021-06-18 18:36:39
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> select 2 | 1;
3
sqlite> select 3 & 1;
1
Oracle only has a "bitand" function, but "bitor" has been posted on Oracle user sites:
create or replace function bitor(p_dec1 number, p_dec2 number) return number is
begin if p_dec1 is null then return p_dec2;
else return p_dec1-bitand(p_dec1,p_dec2)+p_dec2;
end if;
end;
/
That isn't necessary in SQLite.
Searches on these will likely require full table scans, a definite performance disadvantage.