Schemas group names inside one database
public.beers and analytics.monthly_scores belong to different namespaces in the same beer_db database. Qualifying a name chooses its schema explicitly. Practice creates one supplied report row in analytics; it does not move or replace the brewery tables.
Configured and effective search paths
SHOW search_path shows configured entries. current_schemas(false) shows the existing usable explicit schemas. The default "$user" entry refers to a schema named after the current SQL role and is skipped when absent. After SET search_path TO analytics, public, the unqualified report name finds its table in analytics. SET here lasts for this connection.
Creation rights and trusted lookup
Database CONNECT, schema USAGE, schema CREATE, and table privileges are separate. Schema CREATE allows a role to create objects there; it does not grant permission to drop someone else's table. Dropping a table normally requires its owner, the schema owner, or a superuser.
A schema writable by an untrusted role is risky in a search path: an object it creates can affect unqualified name lookup. A schema-qualified name selects that schema directly; an object in public cannot impersonate pg_catalog.some_name merely by sharing its unqualified name.
New databases since PostgreSQL 15 normally omit PUBLIC CREATE on public. Older or migrated databases may retain it, or administrators may already have revoked it. Inspect the actual ACL. In this image, the supplied inspection reports false both before and after REVOKE; the command confirms that policy without removing owner or independently granted rights.
The report you created
analytics.monthly_scores has one supplied report row. Before SET, its unqualified name fails; after SET, that same name finds the row.
A search path is an ordered lookup, not a move of the table. PUBLIC CREATE is already absent in this image; the final REVOKE confirms that policy. Only include schemas writable by trusted roles in a sensitive search path.
Did you know?
A configured search path can contain nonexistent schemas. current_schemas(false) shows which explicit entries actually participate in lookup. PostgreSQL documentation.
Key concepts
search_path
A session-level list of schemas that PostgreSQL searches in order when resolving unqualified table names. The special value "$user" resolves to a schema with the same name as the current user (if it exists). Setting search_path lets you write beers instead of public.beers.
PUBLIC role
PUBLIC represents every SQL role, current and future. REVOKE removes a public grant but does not remove owner, superuser, or independent grant rights.