---
title: "Postgres Roles and Privileges"
description: "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."
url: "https://swe.quest/articles/postgres-roles-and-privileges-34a9d5f1c1427204"
canonical: "https://supabase.com/blog/postgres-roles-and-privileges"
source: "Supabase"
published: "2024-04-11"
difficulty: "medium"
kind: "How-to"
reading_minutes: 20
tags: ["postgres","identity-auth","security"]
---

# Postgres Roles and Privileges

A post on [Supabase](https://swe.quest/sources/supabase.md), published 2024-04-11, 20 min read, How-to. Original: [https://supabase.com/blog/postgres-roles-and-privileges](https://supabase.com/blog/postgres-roles-and-privileges)

## Summary

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. A psql walkthrough with junior\_dev and senior\_dev roles shows granting CREATE on a schema, reading ACLs with \\dn+, \\dp and \\ddp, delegating with WITH GRANT OPTION, and using ALTER DEFAULT PRIVILEGES so tables created later are automatically shared.

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)
- [Security](https://swe.quest/tags/security.md) (Security)

## Prerequisites

- basic SQL ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- psql usage

## Keywords

PostgreSQL, Supabase, psql, GRANT, ALTER DEFAULT PRIVILEGES

## Related posts

- [Postgres Roles: What to Know Before You Begin](https://swe.quest/articles/postgres-roles-what-to-know-before-you-begin-a6df1c63fd1f0301.md): Neon · 2024-07-12 · Medium · 12 min read · PostgreSQL, Identity & auth, Schema migrations
  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.
- [Protecting reserved roles with PostgreSQL Hooks](https://swe.quest/articles/protecting-reserved-roles-with-postgresql-hooks-2e21a72630349824.md): Supabase · 2021-07-02 · Hard · 10 min read · PostgreSQL, Identity & auth, C & C++, Multi-tenancy
  Supabase grants customers the CREATEROLE privilege while preventing them from altering or dropping its internal service roles (like supabase\_storage\_admin) via a C extension, SupaUtils, that hooks PostgreSQL's ProcessUtility\_hook.
- [Storage is now available in Supabase](https://swe.quest/articles/storage-is-now-available-in-supabase-a17d1a6604548758.md): Supabase · 2021-03-30 · Medium · 7 min read · Storage systems, PostgreSQL, Identity & auth, System design, TypeScript
  Supabase Storage is an object store built as a custom TypeScript/Fastify API server behind Kong, with object metadata and access policies kept in each project's Postgres database and objects stored in S3.
- [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.
- [PostgreSQL Event Triggers without superuser access](https://swe.quest/articles/postgresql-event-triggers-without-superuser-access-1e29cc1decfb7891.md): Supabase · 2025-05-08 · Hard · 3 min read · PostgreSQL, Security, Identity & auth
  Supabase's supautils extension lets non-superusers create Postgres Event Triggers by intercepting \`create event trigger\` from a "privileged role" via ProcessUtility\_hook, temporarily elevating to superuser for creation, then assigning ownership back to the privileged role.

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)
