BITWISE_NOT()

All functions > BITWISE > BITWISE_NOT()

Returns the bitwise NOT (complement) of a bitstring, flipping every bit.

Signatures

Returns: Bitwise complement, or NULL if the input is NULL

BITWISE_NOT(expr: BITSTRING) → BITSTRING
sql
ParameterTypeRequiredDescription
exprBITSTRINGYesInput bitstring

Notes

  • Every 0 becomes 1 and every 1 becomes 0
  • The length of the result is the same as the input
  • Returns NULL if the input is NULL

Availability

Available on DuckDB. Not available on Trino, Serving.

Related operators

Examples

FeatureQL
SELECT
    -- Flip all bits
    f1 := BITWISE_NOT('1010'::BITSTRING)::VARCHAR
;
Result
f1 VARCHAR
0101