The SUBSTR function in Oracle extracts a specific number of characters from a string. The syntax is SUBSTR(string, start_position, length), where string is the target string, start_position is the starting extraction position (starting from 1), and length is the number of characters extracted. A negative starting position means counting down from the end of the string, and omitting the length parameter extracts all characters from the starting position to the end of the string.
SUBSTR function in Oracle
SUBSTR function overview
The SUBSTR function is used to extract a specified number of characters from a given string. The syntax is as follows:
<code class="sql">SUBSTR(string, start_position, length)</code>
Where:
SUBSTR function example
Suppose we have a string named "customer_name" whose value is "John Doe".
Negative starting position
The starting position can be a negative number, which means counting down from the end of the string. For example:
Missing length parameter
If the length parameter is omitted, the SUBSTR function will extract all characters from the starting position to the end of the string. For example:
Variations of the SUBSTR function
The SUBSTR function also has the following variants:
The above is the detailed content of substr usage in oracle. For more information, please follow other related articles on the PHP Chinese website!