Apache Hive : HPL/SQL - SUBSTR Function

Last updated: August 12, 2026

Apache Hive : HPL/SQL - SUBSTR Function

SUBSTR function returns a substring from string.

Syntax:

SUBSTR(string, start_pos [, substring_len])

Parameters:

ParameterTypeValueDescription
stringStringVariable or expressionOriginal string
start_posIntegerVariable or expressionStart position of substring (starts from 1)
substring_lenIntegerVariable or expressionLength of substring

Notes:

  • If start_pos is 0 then it is treated as 1
  • SUBSTR and SUBSTRING functions are synonyms

Return Type:

String.

Example:

SUBSTR('Remark', 3); 

Result: ‘mark’

Example:

SUBSTR('Remark', 3, 3); 

Result: ‘mar’

Compatibility: Oracle, IBM DB2 and MySQL.

See also: