Search notes:

Oracle data type RAW and LONG RAW

The data types raw and long raw (as also blob) store a sequence of bytes.
The raw data type is similar to the varchar2 data type, but it is not subject to character conversion in Oracle Net or import/export utilities.
long raw stores binary data up to 2 GB.
long raw (as well as long) is horrible to manage, especially when their size is larger than 32 KB. Therefore, Oracle (and probably everybody else) recommends to use clob instead of long raw.
It should be noted that SQL functions do not operate on the raw datatype and that PL/SQL does not allow to overload functions between raw and char data types.
These limitations give raise to the utl_raw package with which RAWs can be manimpulated.
Packages related to the raw data types are: utl_raw and utl_i18n (for example the procedure utl_i18n.string_to_raw.

rawtohex

--
-- Determine hex representation of "Hello world"
--
select
  rawtohex(
    utl_raw.cast_to_raw('Hello world')
  ) hex
from
  dual;
  
-- 48656C6C6F20776F726C64
Github repository Oracle-Patterns, path: /SQL/datatypes/raw/rawtohex.sql
The return value of rawtohex is limited to 32767 bytes. Additional data is truncated.

See also

Functions related to raw include rawtohex and hextoraw.
Loading binary data into long raw with SQL*Loader
The .NET class Oracle.DataAccess.Types.OracleBinary (with an example that demonstrates how a long raw can be extracted from a table and then be written to a file).
The function dbms_utility.is_bit_set
dbms_stats.convert_raw_value converts a (statistical value stored as raw) back to its original data type and value (see statistical columns in dba_tab_cols).
The OraOLEDB specific connection string attribute ChunkSize
to_lob converts a long or a long raw to a lob data type.
In order for a materialized view to be fast refreshable, the query must not have references to raw or long raw.
The maximum size of raw, varchar2 and nvarchar2 in SQL is controlled by the init parameter max_string_size.
utl_encode contains functions to encode and decode from/to raw data strings.
datatypes

Index