Skip to content

For help, click the link below to get free database assistance or contact our experts for personalized support.

Troubleshooting guide

Cannot create a table. Permission denied in schema public

Every database in PostgreSQL has a default schema called public. A schema stores database objects like tables, views, indexes and allows organizing them into logical groups.

When you create a table without specifying a schema name, it ends up in the public schema by default.

Starting with PostgreSQL 15, non-database owners cannot access the public schema. Therefore, you can either grant privileges to the database for your user using the GRANT command or create your own schema to insert the data.

To create a schema, use the following statement:

CREATE SCHEMA demo;

To ensure all tables end up in your newly created schema, use the following statement ot set the schema:

SET SCHEMA demo;

Replace the demo name with your value.