Difference between SUBSTRING and SUBSTR - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

SUBSTRING and SUBSTR perform identically except when operating on character strings in Teradata mode where the server character set is KANJI1 and the client character set is KanjiEBCDIC.

SUBSTR interprets n1 and n2 as physical units, making the DB2-compliant SUBSTR operate on a byte-by-byte basis. Shift-Out and Shift-In bytes are significant because the result may be formatted incorrectly. For example, the result string may not contain either the opening Shift-Out character or the closing Shift-In character.

Otherwise, if string_expression is character data, then SUBSTRING expects mixed single byte and multibyte character strings and operates on logical characters that are valid for the character set of the session. n1 is a positive integer pointing to the first character of the result and n2 is in terms of logical characters.