Schemas
Updated Oct 11, 2019 ·
Overview
Schemas in PostgreSQL are like directories that organize tables and other database objects. They are essential for managing and structuring data within a database.

Key Uses of Schemas
-
User-specific organization
- Allow each user to have their own set of tables.
- Prevents data interference among users.
- Example: Developers can work with their own schemas using replicas of the production database.
-
Organizational clarity
- Organize distinct components within a database.
- Separate data by business units in a single database.
- Example: Different schemas for each business unit within a company.
Default Schema and Table Creation
New tables are added to the public schema by default. For example, a topic table is stored as public.topic, making it easy to differentiate from tables with the same name in other schemas.
CREATE TABLE topic (
id serial PRIMARY KEY
description NOT NULL
)
To query the table:
SELECT * FROM public.topic;