Oracle substr function usage
Obtain the string substr (string, start_position, [length]) with the specified start position and length in the string.
Substr (string, truncation start position, truncation length) // return the truncated word;
When start_position is set to timing, the string is obtained from left to right;
When start_position is negative, the string is obtained from right to left;
When start_position is 0, the string is obtained from the start position of the string;
Examples:
1. start_position = 0
Select substr ('hello',) FROM dual; -- El
Select substr ('hello', 0, 6) FROM dual; -- hello
Select substr ('hello', 0, 0) FROM dual; -- null
Select substr ('hello', 0) FROM dual; -- hello
2. start_position> 0
Select substr ('hello', 1, 0) FROM dual; -- null
Select substr ('hello', 1, 2) FROM dual; -- he
Select substr ('hello', 1, 6) FROM dual; -- hello
Select substr ('hello', 1) FROM dual; -- hello
3. start_position <0
Select substr ('hello',-3) FROM dual; -- 'llo'
Select substr ('hello',-1) FROM dual; -- 'O'
Select substr ('hello',-3, 2) FROM dual; --'ll'
Select substr ('hello',-7) FROM dual; -- null
Replace () for Oracle Functions ()
Oracle Functions
Differences in case and decode usage and Performance Comparison of Oracle Functions
Simple Oracle functions and stored procedures
The Oracle function obtains the time period in seconds or minutes.