What is a schema in PostgreSQL?

Answer

A schema is a named namespace within a database that contains tables, views, indexes, sequences, and functions. It provides a logical grouping and avoids naming conflicts. The default schema is public. Create with: CREATE SCHEMA myschema;. Reference objects with: myschema.tablename. The search_path variable determines which schemas are searched when a table is referenced without a schema prefix: SET search_path TO myschema, public;. Common uses: multi-tenant applications (one schema per tenant), separating application data from audit tables, or organizing microservice database objects. Schemas are listed with \dn in psql.