---
title: "Postgres Roles: What to Know Before You Begin"
description: "Postgres has no separate users and groups, only roles: a role with LOGIN behaves like a user, and a role without it acts as a group whose privileges pass to its members through inheritance."
url: "https://swe.quest/articles/postgres-roles-what-to-know-before-you-begin-a6df1c63fd1f0301"
canonical: "https://neon.com/blog/postgres-roles"
source: "Neon"
published: "2024-07-12"
difficulty: "medium"
kind: "How-to"
reading_minutes: 12
tags: ["postgres","identity-auth","schema-migrations"]
---

# Postgres Roles: What to Know Before You Begin

A post on [Neon](https://swe.quest/sources/neon.md), published 2024-07-12, 12 min read, How-to. Original: [https://neon.com/blog/postgres-roles](https://neon.com/blog/postgres-roles)

## Summary

Postgres has no separate users and groups, only roles: a role with LOGIN behaves like a user, and a role without it acts as a group whose privileges pass to its members through inheritance. Access depends on privileges at every level of the hierarchy. Reading a table requires CONNECT on the database, USAGE on the schema and SELECT on the table, so revoking schema USAGE silently blocks table-level grants. Common gotchas include the public schema defaults, SECURITY DEFINER functions, search\_path hijacking, implicit owner privileges and inconsistent attribute inheritance. Migrations with tangled role and object dependencies are the biggest pain point, so the post recommends mapping dependencies, writing custom scripts beyond pg\_dump/pg\_restore, testing with a rollback plan, and following least privilege.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Identity & auth](https://swe.quest/tags/identity-auth.md) (Security)
- [Schema migrations](https://swe.quest/tags/schema-migrations.md) (Data & databases)

## Prerequisites

- SQL basics ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- Postgres schemas and tables ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))

## Keywords

PostgreSQL, RBAC, pg\_dump, pg\_restore, SECURITY DEFINER, search\_path, Neon

## Related posts

- [Postgres Roles and Privileges](https://swe.quest/articles/postgres-roles-and-privileges-34a9d5f1c1427204.md): Supabase · 2024-04-11 · Medium · 20 min read · PostgreSQL, Identity & auth, Security
  Postgres access control rests on objects, privileges, roles and ownership: an object's owner holds all privileges on it and is the one who can grant them, so even an admin-like role such as Supabase's non-superuser postgres gets permission denied when granting on a table it neither owns nor holds privileges on.
- [Cracking PostgreSQL Interview Questions](https://swe.quest/articles/cracking-postgresql-interview-questions-e9efeda89524a92a.md): Supabase · 2021-02-27 · Medium · 6 min read · PostgreSQL, SQL, Databases, Identity & auth, Engineering culture
  Interview preparation for the transactional side of PostgreSQL, organized around five areas: data modeling, indexes, views, roles and functions.
- [Declarative Schemas for Simpler Database Management](https://swe.quest/articles/declarative-schemas-for-simpler-database-management-ee2428d0ae8c51e8.md): Supabase · 2025-04-03 · Medium · 4 min read · Schema migrations, PostgreSQL, Developer tools
  Supabase CLI now supports declarative schemas: the desired final state of Postgres tables, views, functions, RLS policies, grants and types lives in versioned .sql files, and a schema diff tool such as migra generates the migration files.
- [Higher-level CRUD Abstraction for Postgres RLS](https://swe.quest/articles/higher-level-crud-abstraction-for-postgres-rls-90207e4bb081ead2.md): Neon · 2024-11-13 · Medium · 3 min read · PostgreSQL, Identity & auth, TypeScript
  Postgres Row-Level Security requires separate USING and WITH CHECK policies per operation, which gets repetitive for CRUD apps.
- [Is Postgres RLS for Everything and Everyone?](https://swe.quest/articles/is-postgres-rls-for-everything-and-everyone-1df08667813a2c82.md): Neon · 2024-11-15 · Medium · 4 min read · PostgreSQL, Identity & auth, Multi-tenancy, Security
  Postgres row-level security is a poor fit for expressing an entire app's authorization model.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
