René Nyffenegger's collection of things on the web | |
René Nyffenegger on Oracle - Most wanted - Feedback
- Follow @renenyffenegger
|
substr [Oracle SQL] | ||
substr(string, position) substr(string, position, length)
The position parameter indicates where the substring starts. It's not zero indexed, that is,
in order to start with the fourth character, the parameter has to be 4:
select substr('1234567890',4) from dual; 4567890
However, if the position parameter is 0, it is treated like being 1:
select substr('1234567890',0, 3) from dual; 123 select substr('1234567890',1, 3) from dual; 123
The parameter can also be negative, in which case it is counted from the right side:
select substr('1234567890',-4,3) from dual; 789
In 10g, there is a regular expression version of substr: regexp_substr.
|