Skip to main content


1. HEXTORAW Function

The HEXTORAW function in H2 database is used to convert a hexadecimal string representation into a raw binary value.

2. Syntax

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



  • hexString: The hexadecimal string that needs to be converted into a raw binary value. It should be a string literal or a column containing hexadecimal values.


  • The HEXTORAW function returns the raw binary value corresponding to the given hexadecimal string.

3. Notes

  • The HEXTORAW function expects a valid hexadecimal string as input. If the input string is not a valid hexadecimal representation, an error will occur.
  • The length of the input hexadecimal string should be an even number. If the length is odd, a leading zero can be added to make it even.
  • The HEXTORAW function can be useful when working with binary data stored as hexadecimal strings, such as in cases of data conversion or manipulation.

4. Examples

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

Example 1 - Converting a hexadecimal string into a raw binary value:

SELECT HEXTORAW('48656C6C6F20576F726C64') AS rawValue;


Hello World

Example 2 - Converting hexadecimal values stored in a column:

CREATE TABLE hex_values (
hexString VARCHAR(100)

INSERT INTO hex_values VALUES (1, '48656C6C6F'), (2, '576F726C64');

SELECT id, hexString, HEXTORAW(hexString) AS rawValue
FROM hex_values;


id | hexString   | rawValue
1 | 48656C6C6F | Hello
2 | 576F726C64 | World
  • rawtohex - Convert a raw binary value into a hexadecimal string.