Who can use this table? Read the privilege edge
Separate a role, an object owner and a privilege edge before you grant access. Privileges and role delegation · Databases.
You are reviewing a report account. The account can connect to the database, but the first query still cannot be treated as “allowed” solely because someone wrote GRANT SELECT. SQL access is a graph: a principal, an object, a privilege, and the authority that created the edge. Keep those four parts separate and the failure becomes diagnosable.
Trace a privilege edge
Read the steps as text
- PostgreSQL 18 profile: analytics_owner owns reporting.orders; report_reader can log in but has no table edge yet. sales_admin already granted database CONNECT, while reporting_owner is authorized to grant schema USAGE but has not done so.
- analytics_owner grants SELECT on customer_id and total to report_reader. The grantee is the role; SELECT is the operation.
- The performed table grant is now visible: analytics_owner owns reporting.orders and report_reader holds SELECT only. report_editor has no table grant, and table ownership has not supplied database or schema authority.
- Ownership is the named authority boundary for the table. The ordinary SELECT edge remains narrower than ownership.
- The requested read is reporting.orders.customer_id and total. report_reader has CONNECT on sales and SELECT on those columns, but no applicable USAGE path on reporting; reporting_owner is authorized to grant USAGE and has not performed it.
- CONNECT and column SELECT are present, but reporting still needs a USAGE edge before the read can reach the table.
- The access path names a role, operation, object scope and grant authority. Database, schema, table, column and sequence privileges remain separate PostgreSQL 18 checks.
A role is the principal named by a privilege edge. PostgreSQL uses one role model for login-capable users and group-like roles; a role may be configured to log in, or it may collect privileges for members. The role is not the same thing as the privilege. SELECT is an operation on an object; report_reader is the principal that may receive it.
An owner is a different boundary. In PostgreSQL, the role that owns a table does not need a separate GRANT to alter or grant that object. A grant to report_reader is narrower: it names an operation such as SELECT on an object. It does not make the reader the owner and does not give the reader an implicit right to redefine the table. This distinction is portable as a design idea, even though ownership and grantable operations vary by engine.
The object scope matters. For a PostgreSQL table reached as reporting.orders, a reader may need CONNECT on the database, USAGE on the schema, and SELECT on the table. A column grant can narrow the readable columns when no broader table, role, or PUBLIC path also applies. A table privilege does not automatically grant privileges on a sequence used by a serial-like column. These are separate edges because the objects and operations are separate. PUBLIC is PostgreSQL’s implicit group of all roles, including roles created later; inspect it before concluding that a direct revoke removed every path.
The concrete dataset uses an invented analytics_owner role, a report_reader role, database sales, schema reporting, and table orders(order_id, customer_id, total, internal_note). In this PostgreSQL profile, sales_admin is authorized to grant CONNECT on sales, reporting_owner is authorized to grant USAGE on reporting, and analytics_owner grants SELECT(customer_id,total) on its table reporting.orders to report_reader. Table ownership alone is not authority over the database or schema. Trace the request from principal to object and identify the edge that supplies it.
Write the access request as a small matrix before writing SQL. Put the principal in one column, the object path in another, and the operation in a third. A request to read reporting.orders.total is different from a request to insert an order, create a table in reporting, or advance an order-number sequence. The same role may receive several edges, but each edge should earn its own reason. This keeps a broad ALL grant from disguising which operation the application really needs. It also gives you a concrete place to check the table, schema, database and dependent sequence.
A revoke is also an edge operation, not a magic global eraser. Revoking a table privilege also revokes the corresponding column privileges for that grantor; revoking individual columns cannot subtract a table-level grant. Inspect other grantors and paths too.
REVOKE SELECT ON reporting.orders FROM report_reader removes the matching grant made through that grant path. A direct grant, membership path, or PUBLIC grant can still contribute the privilege. If a role has WITH GRANT OPTION and has passed a privilege onward, PostgreSQL can reject a default RESTRICT revoke when dependent grants exist; CASCADE removes those dependent grants along the traceable chain. Delegation is the next lesson because the privilege graph alone does not tell you whether a member may create a new edge.
Faded scenario
A billing_owner role grants direct SELECT on billing.invoices to billing_reader, while support_role independently supplies SELECT to that same role through membership with applicable inheritance. PUBLIC has no SELECT edge, so revoking the selected direct grant leaves the same subject with a separate membership path. The later support-ticket example keeps column scope as a separate question.
Follow a revoke path
Read the steps as text
- billing_owner directly granted SELECT on billing.invoices to billing_reader. support_role supplies SELECT to billing_reader through membership with INHERIT true. PUBLIC has no SELECT edge; one direct grant is selected for revocation.
- The selected direct edge is the only edge named for removal. The independent inherited support_role path still supplies SELECT.
- support_reader has SELECT(subject,status) on support.tickets, excluding private_note. schema_owner has not granted USAGE on support, and no alternative USAGE path applies.
- The column grant is present but the relation path still has a named schema boundary.
- Revoke traces one grantor edge, while schema traversal remains a separate scope.
- A role names a principal; a privilege names an operation on an object.
- Ownership carries object authority; an ordinary grant carries only its stated scope.
- Access can come through direct, membership, or
PUBLICedges, so revocation must be traced.
PostgreSQL profile notes
PostgreSQL grants some database privileges such as CONNECT and TEMPORARY to PUBLIC by default. Table, column and sequence privileges are not generally granted to PUBLIC by default. The public schema is a special default: inspect its actual PUBLIC USAGE and, where relevant, legacy PUBLIC CREATE ACL before generalizing. Clusters upgraded from PostgreSQL 14 or earlier may retain that PUBLIC CREATE state. ALTER DEFAULT PRIVILEGES configures future object grants for supported object classes such as tables, schemas, sequences, functions, types and large objects; it does not configure database CONNECT defaults or change existing grants. The exact default set is engine-specific and should not be generalized to all SQL systems.
For a DSA connection, practise hash maps in Fundamentals: a map makes one key-to-value path explicit, while access control can combine direct, role and PUBLIC paths. Next, the role membership and delegation lesson separates inherited use, activation and the authority to pass an edge onward.