Preamble
PostgreSQL substring function allows extracting substring from a string.
Syntax of the substring function in PostgreSQL
substring( string [from start_position] [for length] )
Parameters and function arguments
- string – Source line.
- start_position – Optional. This is the initial position to extract. If this parameter is not specified, the substring function will start from position 1 (which is the first position in the string).
- length – Optional. This is the number of characters to be extracted. If this parameter is not specified, the substring function will return the whole line (from start_position to the end of the string).
Note:
- The first position in the string is 1.
The substring function can be used in the following PostgreSQL versions
PostgreSQL 11, PostgreSQL 10, PostgreSQL 9.6, PostgreSQL 9.5, PostgreSQL 9.4, PostgreSQL 9.3, PostgreSQL 9.2, PostgreSQL 9.1, PostgreSQL 9.0, PostgreSQL 8.4.
Consider some examples of the substring function to understand how to use the substring function in PostgreSQL.
For example:
SELECT substring('Google.com' for 6);
--Result: Google
SELECT substring('Google.com' from 1 to 6);
--Result: Google
SELECT substring('Google.com' from 2 for 5);
--Result: oogle
SELECT substring('Google.com' from 5 to 8);
--Result: le.com
SELECT substring('Google.com' from 8 to 3);
--Result: com
SELECT substring('Google.com' from 8);
--Result: com
Learn PostgreSQL Tutorial; Full Course for Beginners
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 to Improve Insurance Claims Processing with Enteros Database Intelligence Platform
- 28 May 2026
- Database Performance Management
Introduction The insurance industry is rapidly transforming as providers modernize operations, expand digital services, and adopt cloud-native technologies to improve customer experiences, operational efficiency, and business scalability. Modern insurance ecosystems now support: Digital claims processing platforms Customer engagement applications Fraud detection systems Policy management infrastructures Real-time analytics environments AI-driven risk assessment tools Cloud-based insurance services … Continue reading “How to Improve Insurance Claims Processing with Enteros Database Intelligence Platform”
How to Drive Intelligent Healthcare Growth with Enteros Database Intelligence and AI Automation
Introduction The healthcare industry is rapidly evolving as hospitals, healthcare providers, pharmaceutical organizations, and digital health companies accelerate digital transformation initiatives to improve patient care, operational efficiency, and long-term scalability. Modern healthcare ecosystems now support: Electronic health record (EHR) systems Telemedicine platforms AI-powered diagnostics Healthcare analytics environments Patient engagement applications Cloud-native healthcare infrastructures Real-time monitoring … Continue reading “How to Drive Intelligent Healthcare Growth with Enteros Database Intelligence and AI Automation”
Enhancing Digital Customer Experiences Through Proactive Database Performance Management
- 27 May 2026
- Database Performance Management
Introduction In today’s hyper-connected digital economy, customer experience has become the primary differentiator for businesses across industries. Whether it is eCommerce, financial services, SaaS platforms, or digital payment systems, users expect instant responsiveness, seamless interactions, and uninterrupted availability. Even a delay of a few milliseconds can result in lost transactions, abandoned carts, reduced engagement, and … Continue reading “Enhancing Digital Customer Experiences Through Proactive Database Performance Management”
Why Real-Time Database Analytics Is Essential for Modern SaaS Scalability
Modern SaaS platforms operate in an increasingly competitive digital environment where speed, scalability, uptime, and customer experience directly impact business growth. Whether delivering collaboration tools, fintech applications, e-commerce platforms, healthcare solutions, or enterprise productivity software, SaaS providers depend heavily on databases to support real-time digital operations. As user bases grow and cloud-native infrastructures become more … Continue reading “Why Real-Time Database Analytics Is Essential for Modern SaaS Scalability”