urshift
1. URSHIFT Function
=======urshift
1. URSHIFT Function
>>>>>>> 9d19b1c8cb744c8e86d5c15b74d8b5f719ad62beThe URSHIFT function in H2 database is used to perform an unsigned right shift operation on an integer value.
2. Syntax
The syntax for the URSHIFT function in H2 database is as follows:
URSHIFT(value, shift)
Arguments
value
: The integer value on which the unsigned right shift operation needs to be performed.shift
: The number of bits to shift the value to the right.
Return
- The URSHIFT function returns the result of the unsigned right shift operation on the given value.
3. Notes
- The URSHIFT function in H2 database treats the integer value as an unsigned value and performs the right shift operation.
- The shift value should be a non-negative integer.
- If the value is negative or the shift value exceeds the number of bits in the integer representation, the URSHIFT function will return
NULL
. - It is important to ensure that the value and shift are of compatible types to avoid errors and unexpected results.
4. Examples
Here are a few examples demonstrating the usage of the URSHIFT function in H2 database:
Example 1 - Performing an unsigned right shift operation on an integer value:
SELECT URSHIFT(10, 2) AS result;
Output:
result
------
2
Example 2 - Performing an unsigned right shift operation on a column of integer values:
CREATE TABLE numbers (
id INT PRIMARY KEY,
value INT
);
INSERT INTO numbers VALUES (1, 20), (2, 30), (3, 40);
SELECT id, value, URSHIFT(value, 3) AS result
FROM numbers;
Output:
id | value | result
---+-------+-------
1 | 20 | 2
2 | 30 | 3
3 | 40 | 5