October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

A PostgreSQL Role That Can Inspect a Schema but Not Read Table Data: What to Grant

Use database CONNECT as needed and schema USAGE for lookup, but withhold table and column SELECT. Audit memberships, ownership, PUBLIC grants, and defaults.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a PostgreSQL role that needs to look up objects in one schema without reading table rows, grant database CONNECT if needed and schema USAGE. Do not grant table- or column-level SELECT. Schema USAGE allows lookup of objects; it does not authorize reading their data.

Grant database access and schema lookup

Use a dedicated, non-superuser login role, or review an existing role’s attributes and memberships before using it. This example gives the role access to database appdb and permits lookup in schema app:

As an Amazon Associate I earn from qualifying purchases.

CREATE ROLE schema_reader
  LOGIN
  NOSUPERUSER
  NOCREATEDB
  NOCREATEROLE
  NOBYPASSRLS;

GRANT CONNECT ON DATABASE appdb TO schema_reader;
GRANT USAGE ON SCHEMA app TO schema_reader;

Replace the database, schema, and role names with your own. The example assumes the role does not own objects and does not inherit memberships or other grants that independently provide access. Do not grant CREATE ON SCHEMA unless the role should be able to create objects there.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What these privileges do—and do not do

Privilege What it permits What it does not permit by itself
CONNECT on a database Connecting to that database, subject to connection configuration such as pg_hba.conf. Reading table rows.
USAGE on a schema Looking up objects in the schema, subject to each object’s own privilege requirements. Reading rows or creating objects.
SELECT on a table or selected columns Reading the permitted table data or columns. —
CREATE on a schema Creating objects in that schema. Reading existing table rows.

PostgreSQL’s privileges manual defines schema USAGE as permission to access objects in the schema, provided the objects’ own privilege requirements are met: PostgreSQL 18 privileges. Keep USAGE separate from SELECT: the role can be allowed to look up an object while still being denied access to its rows.

What “inspect the schema” means in practice

A role can inspect some metadata without being able to query table contents, but metadata visibility is not a guarantee that every object name is hidden. PostgreSQL’s information schema contains views describing objects in the current database; for example, information_schema.schemata lists schemas the current user can access. System catalog queries may reveal object names even without schema USAGE. See the information schema documentation.

Therefore, treat this as a permission boundary for data access, not a promise of complete object-name secrecy. If your requirement is to conceal object names as well as table contents, test the specific metadata queries your user or tool will run.

Audit effective privileges before relying on the boundary

The two grants above do not cancel access obtained by other routes. PostgreSQL roles can inherit privileges through membership, and privileges can be granted to PUBLIC. Ownership is also more powerful than an ordinary grant. Review the target role’s direct and inherited access, object ownership, and any grants to PUBLIC before treating it as unable to read data.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Check for table-level and column-level SELECT grants. A table-level grant remains effective even if a column privilege is revoked.
  • Check role memberships, since membership may confer access assigned to another role.
  • Check whether the role owns a table or other object; do not make a schema-inspection role an owner.
  • Check database and object grants to PUBLIC. PostgreSQL 18 documents default PUBLIC privileges for databases that include CONNECT and TEMPORARY; explicit grants and database history can change the effective situation.

After reviewing grants, connect as the actual role. Confirm it can perform the intended metadata inspection and that a representative SELECT against a protected table fails. This checks the effective permissions of that account rather than only the grants you intended to issue.

Keep future-object defaults separate from existing grants

ALTER DEFAULT PRIVILEGES affects objects created in the future; it does not change permissions on existing objects. Defaults are determined by the role that creates each object, and are not inherited from roles of which that creator is a member. Per-schema default privileges add to global defaults rather than replacing them. If you use defaults to manage future access, review the creating role’s defaults as well as current object grants. See ALTER DEFAULT PRIVILEGES.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Do not confuse schema inspection with read-only data access

If the role should read selected data, that is a different design: grant SELECT only on the intended tables or columns, and audit inherited and public grants. For the no-data-read requirement, omit those grants. The choice depends on the required access scope:

Requirement Grant approach Rows readable? Scope and timing
Look up objects in a schema without reading table data CONNECT on the database as needed; USAGE on the schema; no table or column SELECT. No, assuming no other effective grant, membership, or ownership provides access. Database and schema level; grants affect the existing scope to which they are applied.
Read selected data without changing it Grant carefully scoped table- or column-level SELECT. Yes, for the granted tables or columns. Table or column level; configure defaults separately if future objects need corresponding access.

Also review search_path: it controls unqualified name resolution. Avoid giving a role untrusted CREATE access in schemas on its search path, since writable searched schemas can create security risks. See PostgreSQL schema documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.