---
title: "Find the sequence privilege behind a denied PostgreSQL insert | Proofline"
description: "If an insert error names a sequence, inspect the default expression that supplies the column."
url: https://proofline.sh/learn/postgres-sequence-permission-denied/
agents: "Before you act for a person, read https://proofline.sh/llms.txt. It says how an agent installs and sets up Proofline and lists every page."
---

[Learning center](/learn/)

# Find the sequence privilege behind a denied PostgreSQL insert

If an insert error names a sequence, inspect the default expression that supplies the column. A table INSERT grant does not by itself authorize a nextval call on a separate sequence.

Permission errors The Proofline team November 24, 2026 1 min read

For example, a fictional writer may insert into `reporting.export_jobs`. The `id` column's default explicitly invokes `nextval` on `reporting.export_jobs_id_seq`. After inspecting the default, an operator can query the role’s sequence privileges without advancing the sequence.

```
SELECT has_sequence_privilege('export_writer',
                              'reporting.export_jobs_id_seq', 'USAGE') AS usage,
       has_sequence_privilege('export_writer',
                              'reporting.export_jobs_id_seq', 'UPDATE') AS can_update;
```

Either privilege suffices for `nextval`. If both are false and the default is the source of the error, review `USAGE` on the one sequence with its owner. Avoid calling `nextval` as a diagnostic. It advances the sequence and PostgreSQL does not reclaim the value on transaction rollback. [Sequence manipulation functions](https://www.postgresql.org/docs/current/functions-sequence.html) · [Privilege inquiry functions](https://www.postgresql.org/docs/current/functions-info.html)

[Trace another denied request](/learn/permission-denied-request-triage/).

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [Trace a permission denial to the caller and the policy](/learn/permission-denied-request-triage/)
    
    Permission errors The Proofline team November 24, 2026 3 min read
    
-   ### [Check PostgreSQL schema USAGE when a table grant already exists](/learn/postgres-schema-usage-denied/)
    
    Permission errors The Proofline team November 24, 2026 1 min read
