Skip to content

resetsequence

functions to reset sequences to values contained in tables

resetsequence · functions to reset sequences to values contained in tables

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
101747resetsequenceresetsequence1.0.0ADMINPostgreSQLC

Usage

Sources:

resetsequence — This module contains a single PostgreSQL extension, comprising simple utility functions that help with maintaining sequence values. These functions let you reset the sequences to the maximum values used in table columns that link to them via DEFAULT clauses. Use it when administering or automating the database behavior described above. Use the pinned upstream revision linked above as the API boundary and test it on the target PostgreSQL build.

Core Workflow

CREATE EXTENSION resetsequence;

Install the extension in the intended database, run the smallest upstream example above when available, and verify the installed version and returned values before integrating it into application SQL.

Important Objects

  • resetseq_reset_sequences_in_database() is an extension function and returns setof.
  • resetseq_reset_sequences_in_schema(name) is an extension function and returns setof.
  • resetseq_reset_sequences_in_table(regclass) is an extension function and returns setof.
  • resetseq_sequence_max_value(oid) is an extension function and returns bigint.
  • resetseq_report_type is an extension-defined type.

Requirements and Caveats

  • The reviewed control file declares default version 1.0.0.
  • The control file marks the extension as relocatable.
  • Confirm privileges, supported PostgreSQL versions, upgrade behavior, and failure cases against the pinned source before production use.

Table reader