# Catalog Error: The table or object already exists

> A CREATE statement tried to add a table, view, schema or macro whose name is already taken in the same schema.

Source: https://sqlly.app/errors/duckdb/catalog-table-exists
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: Table with name "t" already exists!
```

## What it means

DuckDB refuses to overwrite catalog objects, so `CREATE TABLE` without `IF NOT EXISTS` fails when the name is taken. The message quotes the name and names the kind of object when it is not a table, for example `Macro Function with name "m" already exists!`.

In scripts that run more than once, this error is the normal second run. The fix is usually to make the statement idempotent rather than to drop data.

## Common causes

- A CREATE TABLE, CREATE VIEW, CREATE SCHEMA or CREATE MACRO without IF NOT EXISTS or OR REPLACE, run a second time.
- A migration that already ran, applied again by a rerun or a second deployment target.
- Two processes creating the same object concurrently.
- The name collides with a different kind of object in the same schema, since DuckDB shares one namespace per schema for tables and views.

## How to fix it

1. Make the statement idempotent so reruns are harmless:

   ```sql
   CREATE TABLE IF NOT EXISTS metrics (id INTEGER, ts TIMESTAMP);
   CREATE OR REPLACE VIEW recent_metrics AS SELECT * FROM metrics WHERE ts > now() - INTERVAL 1 DAY;
   ```
2. Check what already owns the name before replacing it:

   ```sql
   SELECT table_name, table_type FROM information_schema.tables WHERE table_name = 'metrics';
   ```
3. If the old object really must go, drop it explicitly rather than relying on CREATE to overwrite:

   ```sql
   DROP TABLE IF EXISTS metrics;
   ```

## Reproduce it safely

```sql
CREATE TABLE t(a INT);
CREATE TABLE t(a INT);   -- Catalog Error: Table with name "t" already exists!
```

## Questions

### Does CREATE OR REPLACE work for tables?

Yes. CREATE OR REPLACE TABLE drops the existing table and its data, then creates the new one, so use it only when losing the data is intended. Use CREATE TABLE IF NOT EXISTS to keep existing data.

## 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-schema-not-exist): The schema does not exist in this database
- [`SQLITE_ERROR`](https://sqlly.app/errors/sqlite/sqlite-error): SQLite: SQL logic error
- [`42P07`](https://sqlly.app/errors/postgresql/42P07): PostgreSQL: relation already exists

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