BITWISE_SHIFT_LEFT()

All functions > BITWISE > BITWISE_SHIFT_LEFT()

Returns the bitstring shifted left by N positions, filling with zeros on the right.

Signatures

Returns: Shifted bitstring, or NULL if either operand is NULL

BITWISE_SHIFT_LEFT(expr: BITSTRING, n: BIGINT) → BITSTRING
sql
ParameterTypeRequiredDescription
exprBITSTRINGYesInput bitstring
nBIGINTYesNumber of bit positions to shift

Notes

  • Bits shifted beyond the left end are discarded
  • New bits on the right are filled with zeros
  • The length of the result is the same as the input
  • Returns NULL if either input is NULL

Availability

Available on DuckDB. Not available on Trino, Serving.

Related operators

Examples

FeatureQL
SELECT
    -- Shift left by 3
    f1 := BITWISE_SHIFT_LEFT('1001011'::BITSTRING, 3)::VARCHAR
;
Result
f1 VARCHAR
1011000