Skip to main content


1. RSHIFT Function

The RSHIFT function in H2 database is used to perform a right shift operation on a given integer value.

2. Syntax

The syntax for the RSHIFT function in H2 database is as follows:

RSHIFT(value, n)


  • value: The integer value on which the right shift operation needs to be performed.
  • n: The number of positions to shift the bits to the right. It should be a non-negative integer value.


  • The RSHIFT function returns the result of the right shift operation on the given value.

3. Notes

  • The RSHIFT function in H2 database performs a logical right shift operation, which means the leftmost bit is filled with zeros.
  • If the input value is not a valid integer or the shift count n is negative, the RSHIFT function will return NULL.
  • Ensure that the datatype of the input value is compatible with the RSHIFT function to avoid errors.

4. Examples

Here are a few examples demonstrating the usage of the RSHIFT function in H2 database:

Example 1 - Performing a right shift operation on a single value:

SELECT RSHIFT(8, 2) AS result;



Example 2 - Performing a right shift on values stored in a column:

CREATE TABLE numbers (
value INT

INSERT INTO numbers VALUES (1, 16), (2, 10), (3, 5);

SELECT id, value, RSHIFT(value, 2) AS result
FROM numbers;


id | value | result
1 | 16 | 4
2 | 10 | 2
3 | 5 | 1
  • lshift - Perform a left shift operation
  • bitand - Perform a bitwise AND operation
  • bitor - Perform a bitwise OR operation
  • bitxor - Perform a bitwise XOR operation