Preamble
The Oracle/PLSQL INSTR2 function returns substring occurrence in a string using UCS2 code points.
Function Oracle/PLSQL INSTR2 syntax
INSTR2( string_id, substring_id [, start_position_id [, nth_appearance_id ] ] )
Parameters and function arguments
- string_id – search string. string can be CHAR, VARCHAR2, NCHAR or NVARCHAR2. string cannot be CLOB or NCLOB.
- substring_id – substring for search in string. substring can be CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB or NCLOB.
- start_position_id – is the position of the character in the string from which the search starts. This argument is optional. If the argument is omitted, the default is 1. The first position in line 1. If start_position is negative, the INSTR2 function calculates the start_position position in the opposite direction from the end of the line, and then searches for the beginning of the line.
- nth_appearance_id – is nth substring occurrence. The argument is optional. If omitted, it is 1 by default.
The INSTR2 function returns a numeric value. The first position in the line is 1.
If substring is not found in the string, function INSTR2 will return 0.
INSTR2 function in the following versions of Oracle/PLSQL
|
Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i
|
Let’s consider some examples of the INSTR2 function and learn how to use the INSTR2 function in Oracle/PLSQL.
SQL> SELECT INSTR2('NaDvoreTrava', 'a') FROM DUAL;
--Result: 2
SQL> SELECT INSTR2('NaDvoreTrava', 'a', 1, 1) FROM DUAL;
--Result: 2
SQL> SELECT INSTR2('NaDvoreTrava', 'a', 1, 2) FROM DUAL;
--Result: 10
SQL> SELECT INSTR2('NaDvoreTrava', 'a', 1, 3) FROM DUAL;
--Result: 12
SQL> SELECT INSTR2('NaDvoreTrava', 'a', -3, 2) FROM DUAL;
--Result: 2
About Enteros
Enteros offers a patented database performance management SaaS platform. It proactively identifies root causes of complex business-impacting database scalability and performance issues across a growing number of clouds, RDBMS, NoSQL, and machine learning database platforms.
The views expressed on this blog are those of the author and do not necessarily reflect the opinions of Enteros Inc. This blog may contain links to the content of third-party sites. By providing such links, Enteros Inc. does not adopt, guarantee, approve, or endorse the information, views, or products available on such sites.
Are you interested in writing for Enteros’ Blog? Please send us a pitch!
RELATED POSTS
How Do Streaming Services Manage Database Bottlenecks For New Content Releases And Large Live Events?
- 22 September 2026
- Database Performance Management
Streaming platforms can monitor SQL workloads, query latency, transaction volume, resource usage, database waits, locking, and sudden workload changes to avoid database bottlenecks during major live events and content releases. Effective streaming database performance monitoring empowers IT teams to identify performance risks earlier, optimise inefficient queries, plan capacity, and deliver reliable user experiences in times … Continue reading “How Do Streaming Services Manage Database Bottlenecks For New Content Releases And Large Live Events?”
How Do Hospitals Stop Databases From Slowing Down At Emergency and High Patient Admission Times?
Hospitals can avoid database slowdowns during emergency and high-volume admission periods with continual monitoring of SQL workloads, transaction latency, database waits, locking, utilization of resources, connection levels and sudden workload changes. By effectively monitoring hospital database performance, healthcare IT teams can detect bottlenecks sooner, optimize inefficient queries, plan capacity, and maintain reliable access to vital … Continue reading “How Do Hospitals Stop Databases From Slowing Down At Emergency and High Patient Admission Times?”
How Can Banks Prevent Database Slowdowns During High Transaction Volumes?
- 21 September 2026
- Database Performance Management
Banks can protect bank database performance during high transaction volumes by monitoring SQL latency, throughput, locks, waits, CPU, memory, storage I/O, and workload changes continuously. Strong banking database performance also depends on optimizing high-impact queries, establishing baselines, detecting anomalies early, analyzing root causes, and forecasting capacity before demand exceeds available resources. Why Does Bank Database … Continue reading “How Can Banks Prevent Database Slowdowns During High Transaction Volumes?”
How Can Telecom Companies Improve Database Performance and Keep Networks Running Smoothly?
By regularly tracking SQL workloads, query latency, database waits, resource utilisation, locking, and capacity trends, telecom businesses can enhance the performance of their databases. Telecom teams may identify bottlenecks early, minimise service interruption, and maintain dependable customer-facing systems with the use of efficient database performance monitoring. Enteros facilitates proactive performance management by utilising analytics, root … Continue reading “How Can Telecom Companies Improve Database Performance and Keep Networks Running Smoothly?”