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.
- Schemas contain tables, columns, triggers, functions, etc.
- Postgres comes with a
publicschema set up by default.
- It is best practice to use lowercase and underscores when naming schemas. For example:
Creating a schema
Removing a schema
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.