The SUBSTRING function in Oracle is used to extract the specified part from a string. Syntax: SUBSTRING(string, start, length). Parameters: string - the string to extract the substring; start - the starting position of the substring; length (optional) - the length of the substring. Usage: 1. Specify the starting position and length: such as SUBSTRING('Hello World', 3, 6) returns "llo Wo"; 2. Specify the starting position without specifying the length: such as SUBSTRING('Hello World', 3) Return "llo Wor
##Usage of SUBSTRING function in Oracle
##Definition The SUBSTRING function extracts a specified portion from the given string.
<code>SUBSTRING(string, start, length)</code>
For example, to extract from the "Hello World" string, start at position 3 of 6 characters, you can use the following code:
<code>SUBSTRING('Hello World', 3, 6)</code>
Specify the starting position without specifying. Length
<code>SUBSTRING('Hello World', 3)</code>
Truncate the end of the string
<code>SUBSTRING('Hello World', LENGTH('Hello World') - 2)</code>
##Tip
Positional parameters start with 1, instead of 0.
If the supplied length is negative, SUBSTRING will return an empty character. String.
You can use the NEGATIVE parameter to extract a substring starting from the end of the string. For example:<code>SUBSTRING('Hello World', -3)</code>
The above is the detailed content of Usage of substring in oracle. For more information, please follow other related articles on the PHP Chinese website!