<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Pg_sequences on Postgres Scripts</title><link>https://www.postgresscripts.com/tags/pg_sequences/</link><description>Recent content in Pg_sequences on Postgres Scripts</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>PostgresScripts.com</copyright><lastBuildDate>Sat, 20 Jun 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://www.postgresscripts.com/tags/pg_sequences/index.xml" rel="self" type="application/rss+xml"/><item><title>Inspect PostgreSQL Sequences with the pg_sequences View</title><link>https://www.postgresscripts.com/post/inspect-postgresql-sequences-with-pg-sequences/</link><pubDate>Sat, 20 Jun 2026 00:00:00 +0000</pubDate><guid>https://www.postgresscripts.com/post/inspect-postgresql-sequences-with-pg-sequences/</guid><description>
&lt;h2 id="inspect-postgresql-sequences-with-the-pg_sequences-view"&gt;Inspect PostgreSQL Sequences with the pg_sequences View&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;pg_sequences&lt;/code&gt; is the catalog-backed view that exposes every sequence in the current database in one readable row each — &lt;code&gt;start_value&lt;/code&gt;, &lt;code&gt;min_value&lt;/code&gt;, &lt;code&gt;max_value&lt;/code&gt;, &lt;code&gt;increment_by&lt;/code&gt;, &lt;code&gt;cache_size&lt;/code&gt;, &lt;code&gt;cycle&lt;/code&gt;, and the all-important &lt;code&gt;last_value&lt;/code&gt;. It turns a scattered set of per-sequence &lt;code&gt;currval()&lt;/code&gt; lookups into a single audit query.&lt;/p&gt;
&lt;script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1012089347386563"
crossorigin="anonymous"&gt;&lt;/script&gt;
&lt;ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-1012089347386563"
data-ad-slot="7945792173"
data-ad-format="auto"
data-full-width-responsive="true"&gt;&lt;/ins&gt;
&lt;script&gt;
(adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;
&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&gt;
&lt;p&gt;Sequences are easy to create and easy to forget. Every &lt;code&gt;SERIAL&lt;/code&gt; or &lt;code&gt;GENERATED AS IDENTITY&lt;/code&gt; column quietly relies on a sequence object to hand out the next number, and most of the time nobody looks at one until an &lt;code&gt;INSERT&lt;/code&gt; fails with a &amp;quot;nextval: reached maximum value&amp;quot; error. By then the table is blocked for new rows and the fix has to happen under pressure.&lt;/p&gt;</description></item></channel></rss>