Preamble
The Oracle/PLSQL INSTR function returns the n-th occurrence of a substring in a string.
Oracle/PLSQL INSTR function syntax
INSTR( string1, substring1 [, start_position_id [, nth_appearance_id ] ] )
Parameters and function arguments
- string1 – is a search string. A string can be CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB or NCLOB.
- substring1 – is a 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 will start. This argument is optional. If the argument is omitted, the default is 1. The first position in line 1. If the start_position parameter is negative, the INSTR 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 the nth occurrence of the substring. The argument is optional. If omitted, it is 1 by default.
If a substring is not found in a string, the INSTR function will return 0.
The INSTR function can be used in the following versions of Oracle/PLSQL
|
Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i
|
Let’s consider some examples of the INSTR function and learn how to use the INSTR function in Oracle/PLSQL.
SQL> SELECT INSTR('Grass in the Yard', 'a') FROM DUAL;
--Result: 2
SQL> SELECT INSTR('Grass Yard', 'a', 1, 1) FROM DUAL;
--Result: 2
SQL> SELECT INSTR('Grass Outdoors', 'a', 1, 2) FROM DUAL;
--Result: 12
SQL> SELECT INSTR('Grass on the Yard', 'a', 1, 3) FROM DUAL;
--Result: 14
SQL> SELECT INSTR('Grass on the Yard', 'a', -3, 2) FROM DUAL;
--Result: 2
The Oracle INSTR function allows you to search a string for the occurrence of another string
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
Cloud FinOps for Healthcare: How Enteros Database Software and AI SQL Drive RevOps Efficiency
- 19 March 2026
- Database Performance Management
Introduction The healthcare industry is undergoing a rapid digital transformation driven by electronic health records (EHRs), telemedicine, AI-powered diagnostics, patient engagement platforms, and real-time data analytics. Hospitals, healthcare providers, and life sciences organizations are increasingly relying on data-intensive applications and cloud-based infrastructure to deliver high-quality care and operational efficiency. At the heart of these systems … Continue reading “Cloud FinOps for Healthcare: How Enteros Database Software and AI SQL Drive RevOps Efficiency”
Database Optimization for Finance: How Enteros AI SQL and AIOps Enable Cloud FinOps Efficiency
Introduction The financial sector is undergoing a profound digital transformation driven by cloud adoption, real-time data processing, AI-powered analytics, and customer-centric digital services. From online banking and trading platforms to fraud detection systems and regulatory reporting engines, modern financial institutions depend heavily on high-performance database environments. As these systems scale, they introduce a dual challenge:How … Continue reading “Database Optimization for Finance: How Enteros AI SQL and AIOps Enable Cloud FinOps Efficiency”
Cost Attribution for Marketing Platforms: How Enteros AI SQL and AIOps Deliver Data Intelligence
- 18 March 2026
- Database Performance Management
Introduction The marketing sector has evolved into one of the most data-intensive domains in modern business. From digital advertising and customer segmentation to real-time personalization and omnichannel campaigns, marketing platforms today rely on complex technology ecosystems powered by massive volumes of data. Every click, impression, conversion, and interaction generates data that must be processed, analyzed, … Continue reading “Cost Attribution for Marketing Platforms: How Enteros AI SQL and AIOps Deliver Data Intelligence”
How Media Platforms Optimize Growth Management with Enteros Performance Management and Cost Attribution
Introduction The media industry has undergone a massive transformation in the past decade. From traditional broadcasting to digital-first ecosystems, media platforms now operate in a world driven by streaming services, real-time content delivery, personalized recommendations, and global audience engagement. Whether it’s video streaming, music platforms, online publishing, or digital advertising networks, modern media organizations rely … Continue reading “How Media Platforms Optimize Growth Management with Enteros Performance Management and Cost Attribution”