# Catalog Error: The schema does not exist in this database

> A statement referenced a schema that is not in the connected database, so its objects cannot be reached.

Source: https://sqlly.app/errors/duckdb/catalog-schema-not-exist
Last updated: 2026-11-30
License: Text and data [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) (credit SQLly, sqlly.app); code and SQL snippets [MIT](https://opensource.org/license/mit). [Details](https://sqlly.app/license).
Note: Quoted error message text belongs to its database vendor.

- Exception: `Catalog Error`
- Category: Catalog Error

Error message:

```text
Catalog Error: Schema with name no_such_schema does not exist!
```

## What it means

DuckDB resolves qualified names as `database.schema.object`, and this error means the schema part is not one the connection can see. An unqualified name resolves against the search path, which points at the `main` schema of the connected database by default.

Attached databases multiply the places a name can live: every attachment has its own `main` schema, and the same schema name can exist in two databases at once. The wording depends on the statement: `CREATE TABLE analytics.orders` and `DROP SCHEMA analytics` name the schema directly, while a query that reads through a missing schema reports the table instead, as `Table with name "analytics.orders" does not exist because schema "analytics" does not exist.`. In practice the name is misspelled, the object was created on another connection or another database, or a qualification points at the wrong attached alias.

## Common causes

- A typo or wrong case in a qualified name such as analytics.orders.
- The schema lives in an attached database, and the query used the wrong alias, or the ATTACH never ran on this connection.
- The table was created in `main` while the query looks for it in another schema, or the search_path was changed.
- A migration that creates the schema never ran on this connection.

## How to fix it

1. List the schemas the connection can actually see:

   ```sql
   SELECT database_name, schema_name
   FROM duckdb_schemas()
   ORDER BY 1, 2;
   ```
2. Create the schema if it should exist, and qualify names while you populate it:

   ```sql
   CREATE SCHEMA analytics;
   CREATE TABLE analytics.orders (id INTEGER, total DECIMAL(10,2));
   ```
3. Qualify with the attached database when the table lives there:

   ```sql
   SELECT * FROM warehouse.main.orders LIMIT 5;
   ```
4. Point unqualified names at the right schema:

   ```sql
   SET search_path = 'analytics,main';
   ```

## Reproduce it safely

```sql
CREATE TABLE no_such_schema.t(a INTEGER);   -- Catalog Error: Schema with name no_such_schema does not exist!
```

## Questions

### Where do temporary tables and views live?

In the temp database, under temp.main. Qualify them as temp.main.name when another schema is first in the search path.

### Why is my table invisible after ATTACHing a second database?

Each database has its own schemas. An unqualified name resolves inside the connected database, not the attachment, so qualify it as attached.main.table or change the search path.

## Related errors

- [`Catalog Error`](https://sqlly.app/errors/duckdb/catalog-table-not-exist): The table does not exist in this database
- [`Catalog Error`](https://sqlly.app/errors/duckdb/catalog-table-exists): The table or object already exists
- [`3F000`](https://sqlly.app/errors/postgresql/3F000): PostgreSQL: schema does not exist
- [`1049`](https://sqlly.app/errors/mysql/1049): MySQL: Unknown database

The code and message text are from the [DuckDB documentation](https://duckdb.org/docs/).
