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
AI-Powered Retail Growth: How Enteros Aligns Database Performance with RevOps Efficiency
- 22 December 2025
- Database Performance Management
Introduction The retail sector is experiencing a profound digital shift. Omnichannel commerce, hyper-personalized customer experiences, dynamic pricing, real-time inventory visibility, and rapid fulfillment have become the standard rather than the exception. Behind every seamless customer interaction lies a complex technology ecosystem powered by databases, cloud infrastructure, SaaS platforms, analytics engines, and AI-driven applications. As retail … Continue reading “AI-Powered Retail Growth: How Enteros Aligns Database Performance with RevOps Efficiency”
Modernizing Banking IT: How Enteros Combines Database Performance Management, AIOps, and Cloud FinOps
Introduction The banking sector is undergoing one of the most significant technology transformations in its history. Digital banking platforms, real-time payments, mobile apps, AI-driven fraud detection, open banking APIs, and regulatory reporting systems now operate at massive scale and speed. At the heart of all these capabilities lies a complex web of databases and cloud … Continue reading “Modernizing Banking IT: How Enteros Combines Database Performance Management, AIOps, and Cloud FinOps”
Intelligent Healthcare IT Economics: How Enteros Unifies Cost Attribution, Performance Management, and Cloud FinOps with AIOps
- 21 December 2025
- Database Performance Management
Introduction Healthcare organizations today are under immense pressure to deliver better patient outcomes while managing rising operational costs, complex regulatory requirements, and rapidly expanding digital ecosystems. From electronic health records (EHRs) and clinical decision systems to telehealth platforms, AI-driven diagnostics, and revenue cycle applications, healthcare IT environments have become both mission-critical and highly complex. At … Continue reading “Intelligent Healthcare IT Economics: How Enteros Unifies Cost Attribution, Performance Management, and Cloud FinOps with AIOps”
Smart Real Estate IT Operations: How Enteros Uses AIOps to Optimize Database Performance and Cost Estimation
Introduction The real estate sector is undergoing a profound digital transformation. What was once a traditionally asset-heavy, manually operated industry is now driven by data, cloud platforms, and real-time analytics. From property management systems and leasing platforms to smart building technologies, digital twin models, and AI-powered valuation engines, modern real estate enterprises rely heavily on … Continue reading “Smart Real Estate IT Operations: How Enteros Uses AIOps to Optimize Database Performance and Cost Estimation”