Schemas are like "folders". They help to keep your database organized.

Schemas are particularly useful for security. You can set different permissions on each schema. For example, you might want to use a public schema for user-facing data, and an auth schema for all logins and secured data.

create schema schema_name;


  • Schemas contain tables, columns, triggers, functions, etc.
  • Postgres comes with a public schema set up by default.
  • It is best practice to use lowercase and underscores when naming schemas. For example: schema_name, not Schema Name.


Creating a schema

create schema schema_name;

Removing a schema

drop schema if exists schema_name;

Using special characters

Although it's not recommended, you can use uppercase and spaces when naming your schema by wrapping the name with double-quotes. As a result, you will always need to use double-quotes when referencing your schema.

create schema "Schema Name";