SQLMentor // glossary

Database Schema

A schema is a named collection of database objects — tables, views, indexes, procedures — that belong to a user or namespace. It organizes objects and controls who can access them.

In Oracle a schema is tied to a user account; in PostgreSQL and SQL Server a schema is a namespace within a database that can group related objects (e.g. sales.orders vs hr.employees).

Schemas prevent naming collisions and let you grant permissions at the group level, so a reporting role can be given read access to an entire schema at once.

Example

CREATE SCHEMA sales;
CREATE TABLE sales.orders (order_id INT PRIMARY KEY, total NUMERIC);