Skip to content

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.

Get expert help

If you need assistance, visit the community forum for comprehensive and free database knowledge, or contact our Percona Database Experts for professional support and services.