Skip to content

bit_or ​

Applies bitwise OR to a sequence of integer values. NULL inputs are skipped.

Syntax

text
bit_or(value)

Arguments

  • value — An exact signed or unsigned integer, including native widths through 256 bits. Floating-point values, decimals and text raise TYPE_MISMATCH.

Returned value

The exact integer formed by applying OR to every admitted value. A declared integer width is retained; mixed runtime integer classes widen within native bounds. A result outside the supported native range raises NUMERIC_OVERFLOW.

An empty input, or an input containing only NULL, returns NULL.

Examples

Combining bit masks

In binary, 1100 OR 1010 = 1110:

sql
CREATE TABLE masks (value INTEGER);
INSERT INTO masks VALUES (12), (10), (NULL);
sql
SELECT bit_or(value) AS combined_mask
FROM masks
FORMAT csv;
text
14

No non-NULL masks

sql
CREATE TABLE null_masks (value INTEGER);
INSERT INTO null_masks VALUES (NULL), (NULL);
sql
SELECT bit_or(value)
FROM null_masks
FORMAT csv;
text
\N

See bit functions for scalar bit operations.