---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://ydb.tech/docs/en/postgresql/statements/drop_table.md?version=v25.3
  - https://ydb.tech/docs/ru/postgresql/statements/drop_table.md?version=v25.3
  - href: en/postgresql/statements/drop_table.md
    type: text/markdown
    title: Markdown version
  - href: ../../llms.txt
    type: text/markdown
    title: llms.txt
sourcePath: en/core/postgresql/statements/drop_table.md
---
> **Documentation Index:** Fetch the complete configuration index at https://ydb.tech/docs/en/llms.txt

# DROP TABLE

<!-- markdownlint-disable blanks-around-fences -->

<!-- source: en/postgresql/_includes/alert_preview.md -->
{% note warning %}

At the moment, YDB's compatibility with PostgreSQL **is under development**, so not all PostgreSQL constructs and [functions](https://ydb.tech/docs/en/postgresql/functions.md?version=v25.3) are supported yet. PostgreSQL compatibility is available for testing in the form of a Docker container, which can be deployed by following these [instructions](https://ydb.tech/docs/en/postgresql/docker-connect.md?version=v25.3).

{% endnote %}
<!-- endsource: en/postgresql/_includes/alert_preview.md -->

Syntax of the `DROP TABLE` statement:

<!-- source: en/postgresql/_includes/statements/drop_table/syntax.md -->
```sql
DROP TABLE [IF EXISTS] <table name>;
```
<!-- endsource: en/postgresql/_includes/statements/drop_table/syntax.md -->

The `DROP TABLE <table name>;` statement is used to delete a table. For example: `DROP TABLE people;`. If the table being deleted does not exist – an error message will be displayed:

```text
Error: Cannot find table '...' because it does not exist or you do not have access permissions.
Please check correctness of table path and user permissions., code: 2003.
```

In a number of scenarios, such behavior is not required. For example, if we want to ensure the creation of a new table by deleting the previous one within a single SQL script or a sequence of SQL commands. In such cases, the instruction `DROP TABLE IF EXISTS <table name>` is used. If the table does not exist, the instruction will return a `DROP TABLE` message, not an error.

<!-- source: en/postgresql/_includes/alert_locks.md -->
{% note info %}

Unlike PostgreSQL, YDB uses optimistic locking. This means that transactions check the conditions for the necessary locks at the end of their operation, not at the beginning. If the lock has been violated during the transaction's execution, such a transaction will end with a `Transaction locks invalidated` error. In this case, you can try to execute a similar transaction again.

{% endnote %}
<!-- endsource: en/postgresql/_includes/alert_locks.md -->
