<character substring function> ::=

SUBSTRING ( <character value expression> FROM start-position

[ FOR string-length ] [ USING { CHARACTERS | OCTETS } ] )


The SUBSTRING function returns a subset of characters from the source string.
The start-position argument specifies the ordinal position within the source string where the substring starts.
The string-length argument specifies how many characters or octets shall be copied from the source string.
If CHARACTERS is specified, or the USING clause is omitted, then start-position is the ordinal character position within the source string. If OCTETS is specified, then start-position is the byte position.
If the declared type of the character value expression is a fixed-length or variable-length character string type, then the data type of the result is CHARACTER VARYING or NATIONAL CHARACTER VARYING with a length equal to the fixed length or maximum variable length of the character value expression, otherwise the data type of the result is CHARACTER LARGE OBJECT or NATIONAL CHARACTER LARGE OBJECT.
If either of the arguments are null, then the result is null.




SUBSTRING( 'Hello World' FROM 1 )

'Hello World'

SUBSTRING( 'Hello World' FROM 1 FOR 5 )


SUBSTRING( 'Hello World' FROM 7 )


SUBSTRING( 'Hello World' FROM 7 FOR 5 )



SQL:2003 standard


Core SQL

Home | Site Contents | Documentation | NexusDB Manual V4 | SQL Reference | SQL Functions | String Value Functions