

# ALTER TABLE and DROP TABLE statements in DuckDB

Use `ALTER TABLE` to add, drop, and rename the columns of a table, and to register and remove the partitions of a Hive table. Use `DROP TABLE` to remove a table from the AWS Glue Data Catalog. For Hive tables and for Apache Iceberg tables in the AWS Glue Data Catalog, these statements change the table definition only. They do not rewrite the data files of the table, and `DROP TABLE` does not delete them.

An `ALTER TABLE` statement that changes columns makes one change, so run one statement for each column that you add, drop, or rename. A statement that registers or removes partitions can name several partitions.

In these statements, `table_name` is the name of a table in the AWS Glue Data Catalog, such as `sales_db.alt_orders_hive`. For more information about how DuckDB resolves table names, see [SQL reference](duckdb-sql-reference.md).

The examples use six small tables in a database named `sales_db`. The `alt_orders_hive` table is a Hive table in Parquet format, `alt_orders_csv` is a Hive table in CSV format, and `alt_orders_iceberg` is an Iceberg table. Each has the columns `order_id` (`INTEGER`), `customer` (`VARCHAR`), and `amount` (`DECIMAL(10,2)`, or `DOUBLE` in the CSV table). The `amount` column holds the order total in US dollars (USD). The Parquet and Iceberg tables hold orders 1 through 3, and the CSV table holds orders 1 and 2. The `alt_events_hive` table is a Hive table in Parquet format that is partitioned by `dt`. It has the columns `event_id` (`INTEGER`), `event` (`VARCHAR`), and `dt` (`VARCHAR`), and holds two events on `2026-10-01` and one on `2026-10-02`. The `DROP TABLE` examples remove `alt_old_orders_hive`, a Hive table in Parquet format, and `alt_old_orders_iceberg`, an Iceberg table.

Run the examples in the order in which this topic shows them, because many of them change the tables that other examples read.

## Synopsis
<a name="athena-duckdb-statement-alter-drop-table-synopsis"></a>

```sql
ALTER TABLE {{table_name}} ADD COLUMN
    [ IF NOT EXISTS ] {{column_name}} {{data_type}}

ALTER TABLE {{table_name}} DROP COLUMN
    [ IF EXISTS ] {{column_name}}

ALTER TABLE {{table_name}} RENAME COLUMN {{column_name}} TO
    {{new_column_name}}

ALTER TABLE {{table_name}} ADD [ IF NOT EXISTS ]
    PARTITION ( {{partition_column}} = {{value}} [, ...] )
        [ LOCATION '{{location}}' ] [ ... ]

ALTER TABLE {{table_name}} DROP [ IF EXISTS ]
    PARTITION ( {{partition_column}} = {{value}} [, ...] )
        [, ...]

DROP TABLE [ IF EXISTS ] {{table_name}}
```

## `ADD COLUMN`
<a name="athena-duckdb-statement-alter-drop-table-add-column"></a>

`ALTER TABLE` `ADD COLUMN` adds a column after the existing data columns of a table. In a partitioned Hive table, the new column comes before the partition columns, which are always last.

`ADD COLUMN` does not rewrite the data files. Rows that the table already holds have `NULL` in the new column, and rows that you write after the change can have values in it. An exception is a Hive table in Parquet format whose data files already hold a column with the same name, such as a column that you dropped earlier. Such a table reads the existing values of that column from the files.

With `IF NOT EXISTS`, the statement does nothing if the table already has a column with that name. Without `IF NOT EXISTS`, the statement fails if the table already has a column with that name.

### Syntax
<a name="athena-duckdb-statement-alter-drop-table-add-column-syntax"></a>

```sql
ALTER TABLE {{table_name}} ADD COLUMN
    [ IF NOT EXISTS ] {{column_name}} {{data_type}}
```

In the syntax, replace each placeholder as follows:

**{{column\_name}}**  
The name of the new column.

**{{data\_type}}**  
The data type of the new column, such as `VARCHAR`, `BIGINT`, or `DECIMAL(4,2)`.

### Examples
<a name="athena-duckdb-statement-alter-drop-table-add-column-examples"></a>

The following SQL statement adds a `discount` column of type `DECIMAL(4,2)` to the Hive table `alt_orders_hive`.

```sql
ALTER TABLE sales_db.alt_orders_hive ADD COLUMN discount DECIMAL(4,2)
```

The statement returns no rows.

The following SQL query lists the columns of `alt_orders_hive` in the order of the table definition. The new column comes last.

```sql
SELECT column_name, data_type
FROM duckdb_columns()
WHERE schema_name = 'sales_db'
    AND table_name = 'alt_orders_hive'
ORDER BY column_index
```

The query returns the following results.


| column\_name | data\_type | 
| --- | --- | 
| `order_id` | `INTEGER` | 
| `customer` | `VARCHAR` | 
| `amount` | `DECIMAL(10,2)` | 
| `discount` | `DECIMAL(4,2)` | 

The following SQL statement inserts an order that has a discount.

```sql
INSERT INTO sales_db.alt_orders_hive VALUES (
    4, 'dave', 310.00, 0.10
)
```

The statement returns no rows.

The following SQL query reads the discounts. The orders that the table held before the change have `NULL` in the new column.

```sql
SELECT order_id, customer, discount
FROM sales_db.alt_orders_hive
ORDER BY order_id
```

The query returns the following results.


| order\_id | customer | discount | 
| --- | --- | --- | 
| `1` | `alice` | `NULL` | 
| `2` | `bob` | `NULL` | 
| `3` | `carol` | `NULL` | 
| `4` | `dave` | `0.10` | 

The following SQL statement adds the same column again with `IF NOT EXISTS`. The column already exists, so the statement succeeds and changes nothing.

```sql
ALTER TABLE sales_db.alt_orders_hive ADD COLUMN IF NOT EXISTS discount DECIMAL(4,2)
```

The statement returns no rows.

The following SQL statement adds a `region` column to the Iceberg table `alt_orders_iceberg`.

```sql
ALTER TABLE sales_db.alt_orders_iceberg ADD COLUMN region VARCHAR
```

The statement returns no rows.

The following SQL statement inserts an order with a region.

```sql
INSERT INTO sales_db.alt_orders_iceberg VALUES (
    4, 'dave', 310.00, 'north'
)
```

The statement returns no rows.

The following SQL query reads the regions. The orders that the table held before the change have `NULL` in the new column.

```sql
SELECT order_id, customer, region
FROM sales_db.alt_orders_iceberg
ORDER BY order_id
```

The query returns the following results.


| order\_id | customer | region | 
| --- | --- | --- | 
| `1` | `alice` | `NULL` | 
| `2` | `bob` | `NULL` | 
| `3` | `carol` | `NULL` | 
| `4` | `dave` | `north` | 

### Considerations
<a name="athena-duckdb-statement-alter-drop-table-add-column-considerations"></a>

A column that you add to a Hive table cannot have a default value. On a Hive table, `ADD COLUMN` with a `DEFAULT` clause fails.

On any table, `ADD COLUMN` fails if the new column has a `NOT NULL` or `UNIQUE` constraint, or if its default value is an expression or a struct value, such as `DEFAULT now()`, `DEFAULT 1 + 1`, or `DEFAULT {'a': 1}`.

### Differences from Athena engine version 3
<a name="athena-duckdb-statement-alter-drop-table-add-column-differences-from-engine-version-3"></a>

In Athena engine version 3, you can add several columns in one statement with `ADD COLUMNS`. In DuckDB, use `ADD COLUMN`, and run one statement for each column that you add.

## `DROP COLUMN`
<a name="athena-duckdb-statement-alter-drop-table-drop-column"></a>

`ALTER TABLE` `DROP COLUMN` removes a column from the table definition, and queries of the table no longer return it. `DROP COLUMN` does not rewrite the data files, so they still hold the values of the dropped column.

With `IF EXISTS`, the statement does nothing if the table has no column with that name. Without `IF EXISTS`, the statement fails if the table has no column with that name.

### Syntax
<a name="athena-duckdb-statement-alter-drop-table-drop-column-syntax"></a>

```sql
ALTER TABLE {{table_name}} DROP COLUMN
    [ IF EXISTS ] {{column_name}}
```

In the syntax, replace each placeholder as follows:

**{{column\_name}}**  
The name of the column to drop.

### Examples
<a name="athena-duckdb-statement-alter-drop-table-drop-column-examples"></a>

The following SQL statement drops the `discount` column from `alt_orders_hive`.

```sql
ALTER TABLE sales_db.alt_orders_hive DROP COLUMN discount
```

The statement returns no rows.

The following SQL query reads every column of `alt_orders_hive`. The `discount` column is no longer part of the table. Each amount is in US dollars (USD).

```sql
SELECT * FROM sales_db.alt_orders_hive ORDER BY order_id
```

The query returns the following results.


| order\_id | customer | amount | 
| --- | --- | --- | 
| `1` | `alice` | `120.50` | 
| `2` | `bob` | `75.00` | 
| `3` | `carol` | `42.25` | 
| `4` | `dave` | `310.00` | 

The following SQL statement drops the same column again with `IF EXISTS`. The column no longer exists, so the statement succeeds and changes nothing.

```sql
ALTER TABLE sales_db.alt_orders_hive DROP COLUMN IF EXISTS discount
```

The statement returns no rows.

The following SQL statement drops the `region` column from the Iceberg table `alt_orders_iceberg`.

```sql
ALTER TABLE sales_db.alt_orders_iceberg DROP COLUMN region
```

The statement returns no rows.

The following SQL query reads every column of `alt_orders_iceberg`. The `region` column is no longer part of the table. Each amount is in US dollars (USD).

```sql
SELECT *
FROM sales_db.alt_orders_iceberg
ORDER BY order_id
```

The query returns the following results.


| order\_id | customer | amount | 
| --- | --- | --- | 
| `1` | `alice` | `120.50` | 
| `2` | `bob` | `75.00` | 
| `3` | `carol` | `42.25` | 
| `4` | `dave` | `310.00` | 

### Considerations
<a name="athena-duckdb-statement-alter-drop-table-drop-column-considerations"></a>

You cannot drop a column of a Hive table in CSV format. Because DuckDB reads CSV files by column position, the values in the existing files would no longer line up with the columns.

You cannot drop a partition column of a Hive table.

A Hive table in Parquet format matches the columns of its data files by name. If you drop a column and later add a column with the same name, the table reads the values of the dropped column from the existing files again. An Iceberg table keeps track of each column by an ID. Because of this, a column that you add with the name of a dropped column is a new column, and the existing rows have `NULL` in it.

## `RENAME COLUMN`
<a name="athena-duckdb-statement-alter-drop-table-rename-column"></a>

`ALTER TABLE` `RENAME COLUMN` gives a column a new name. The column keeps its values on Iceberg tables and on Hive tables in CSV format. An Iceberg table keeps track of each column by an ID, not by its name. DuckDB reads CSV files by column position, not by column name.

On a Hive table in another format, such as Parquet or JSON, `RENAME COLUMN` fails. Because DuckDB matches the columns of those data files by name, the existing rows would have `NULL` in the column after a rename. To rename such a column anyway, and accept that the existing rows have `NULL` in it, replace the columns of the table with the `glue_replace_columns` function. For more information about `glue_replace_columns`, see [AWS Glue Data Catalog functions in DuckDB](duckdb-functions-glue.md).

### Syntax
<a name="athena-duckdb-statement-alter-drop-table-rename-column-syntax"></a>

```sql
ALTER TABLE {{table_name}} RENAME COLUMN {{column_name}} TO
    {{new_column_name}}
```

In the syntax, replace each placeholder as follows:

**{{column\_name}}**  
The current name of the column.

**{{new\_column\_name}}**  
The new name of the column. The table must not already have a column with this name.

### Examples
<a name="athena-duckdb-statement-alter-drop-table-rename-column-examples"></a>

The following SQL statement renames the `customer` column of the Iceberg table `alt_orders_iceberg` to `buyer`.

```sql
ALTER TABLE sales_db.alt_orders_iceberg RENAME COLUMN customer TO buyer
```

The statement returns no rows.

The following SQL query reads the renamed column. The existing rows keep their values.

```sql
SELECT order_id, buyer
FROM sales_db.alt_orders_iceberg
ORDER BY order_id
```

The query returns the following results.


| order\_id | buyer | 
| --- | --- | 
| `1` | `alice` | 
| `2` | `bob` | 
| `3` | `carol` | 
| `4` | `dave` | 

The following SQL statement renames the `customer` column of the CSV table `alt_orders_csv` to `buyer`.

```sql
ALTER TABLE sales_db.alt_orders_csv RENAME COLUMN customer TO buyer
```

The statement returns no rows.

The following SQL query reads the renamed column of the CSV table. The existing rows keep their values.

```sql
SELECT order_id, buyer
FROM sales_db.alt_orders_csv
ORDER BY order_id
```

The query returns the following results.


| order\_id | buyer | 
| --- | --- | 
| `1` | `alice` | 
| `2` | `bob` | 

### Considerations
<a name="athena-duckdb-statement-alter-drop-table-rename-column-considerations"></a>

You cannot rename a partition column of a Hive table, because the folders of the existing partitions are named after it.

### Differences from Athena engine version 3
<a name="athena-duckdb-statement-alter-drop-table-rename-column-differences-from-engine-version-3"></a>

In Athena engine version 3, you rename a column of an Iceberg table with `CHANGE COLUMN`, as in `ALTER TABLE orders CHANGE COLUMN customer buyer string`. In DuckDB, use `RENAME COLUMN`, as in `ALTER TABLE orders RENAME COLUMN customer TO buyer`.

## Rename a table
<a name="athena-duckdb-statement-alter-drop-table-rename-table"></a>

DuckDB does not support `ALTER TABLE` `RENAME TO`. To give a table a new name, use `CREATE TABLE AS SELECT` to copy it to a table with the new name. Then drop the original table with `DROP TABLE`. For more information about `CREATE TABLE AS SELECT`, see [`CREATE TABLE AS`](duckdb-statement-create-table.md#athena-duckdb-statement-create-table-create-table-as).

To rename an unpartitioned Hive table without copying its data files, drop the table, and then create a table with the new name and the same columns, `format`, and `location`. For a CSV table, also give the new table the same `delimiter`, `header`, `quote`, and `escape` properties, so that it reads the files in the same way. Because `DROP TABLE` leaves the data files in place, the new table reads them.

### Differences from Athena engine version 3
<a name="athena-duckdb-statement-alter-drop-table-rename-table-differences-from-engine-version-3"></a>

DuckDB does not support the Athena engine version 3 statement `ALTER TABLE` `RENAME TO`. Copy the table under the new name, and then drop the original table.

## `ADD PARTITION`
<a name="athena-duckdb-statement-alter-drop-table-add-partition"></a>

`ALTER TABLE` `ADD PARTITION` registers one or more partitions of a partitioned Hive table in the AWS Glue Data Catalog. Name each partition with a value for every partition column. Without `LOCATION`, the location of a partition is a folder under the table location that is named after the partition, such as `dt=2026-10-03`.

The statement registers metadata only. It does not create, move, or delete files in Amazon S3. Queries of the table read the data files under the location of each registered partition.

To register several partitions in one statement, list them one after another without commas, each with its own optional `LOCATION`. With `IF NOT EXISTS`, the statement does not change partitions that are already registered. Without `IF NOT EXISTS`, the statement fails if a partition is already registered.

The statement returns one row for each partition that it names, with the columns `action`, `partition`, and `location`. With `IF NOT EXISTS`, a partition that was already registered still has a row in the result. For such a partition, the `location` column shows the location that the statement would have registered, which is not necessarily the location of the registered partition. To read the registered location, use the `glue_partitions` function.

You can also register partitions with the `glue_add_partition` function, or register the partition folders under the table location with the `glue_repair_table` function. For more information about these functions, see [AWS Glue Data Catalog functions in DuckDB](duckdb-functions-glue.md).

### Syntax
<a name="athena-duckdb-statement-alter-drop-table-add-partition-syntax"></a>

```sql
ALTER TABLE {{table_name}} ADD [ IF NOT EXISTS ]
    PARTITION ( {{partition_column}} = {{value}} [, ...] )
        [ LOCATION '{{location}}' ]
    [ PARTITION ( {{partition_column}} = {{value}} [, ...] )
        [ LOCATION '{{location}}' ] ... ]
```

In the syntax, replace each placeholder as follows:

**{{partition\_column}}**  
A partition column of the table. Give a value for every partition column of the table.

**{{value}}**  
The value of the partition column for the partition, such as `'2026-10-03'`.

**{{location}}**  
The Amazon S3 location of the data files of the partition. DuckDB stores the location without a trailing slash. This parameter is optional.

### Examples
<a name="athena-duckdb-statement-alter-drop-table-add-partition-examples"></a>

The following SQL statement registers the partition `dt = '2026-10-03'` of the Hive table `alt_events_hive` at its default location. The result shows the location, a folder named `dt=2026-10-03` under the table location.

```sql
ALTER TABLE sales_db.alt_events_hive ADD PARTITION (
    dt = '2026-10-03'
)
```

The statement returns the following result.


| action | partition | location | 
| --- | --- | --- | 
| `add partition` | `2026-10-03` | `s3://amzn-s3-demo-bucket/tables/alt_events_hive/dt=2026-10-03` | 

The following SQL statement registers a partition at a location that you choose. The location in the result has no trailing slash.

```sql
ALTER TABLE sales_db.alt_events_hive
ADD PARTITION (
    dt = '2026-10-04'
) LOCATION 's3://amzn-s3-demo-bucket/tables/alt_events_hive/imports/2026-10-04/'
```

The statement returns the following result.


| action | partition | location | 
| --- | --- | --- | 
| `add partition` | `2026-10-04` | `s3://amzn-s3-demo-bucket/tables/alt_events_hive/imports/2026-10-04` | 

The following SQL statement registers the `2026-10-03` partition again with `IF NOT EXISTS`. The partition is already registered, so the statement succeeds and leaves the partition as it is. The result still has a row for the partition.

```sql
ALTER TABLE sales_db.alt_events_hive ADD IF NOT EXISTS PARTITION (
    dt = '2026-10-03'
)
```

The statement returns the following result.


| action | partition | location | 
| --- | --- | --- | 
| `add partition` | `2026-10-03` | `s3://amzn-s3-demo-bucket/tables/alt_events_hive/dt=2026-10-03` | 

The following SQL statement registers two partitions in one statement. The result has one row for each partition.

```sql
ALTER TABLE sales_db.alt_events_hive
ADD PARTITION (
    dt = '2026-10-05'
) PARTITION (dt = '2026-10-06')
```

The statement returns the following results.


| action | partition | location | 
| --- | --- | --- | 
| `add partition` | `2026-10-05` | `s3://amzn-s3-demo-bucket/tables/alt_events_hive/dt=2026-10-05` | 
| `add partition` | `2026-10-06` | `s3://amzn-s3-demo-bucket/tables/alt_events_hive/dt=2026-10-06` | 

The following SQL query lists the partitions of `alt_events_hive` and their locations. The table already had the `2026-10-01` and `2026-10-02` partitions, and the examples in this section registered the other four.

```sql
SELECT dt, location
FROM glue_partitions('sales_db.alt_events_hive')
ORDER BY dt
```

The query returns the following results.


| dt | location | 
| --- | --- | 
| `2026-10-01` | `s3://amzn-s3-demo-bucket/tables/alt_events_hive/dt=2026-10-01` | 
| `2026-10-02` | `s3://amzn-s3-demo-bucket/tables/alt_events_hive/dt=2026-10-02` | 
| `2026-10-03` | `s3://amzn-s3-demo-bucket/tables/alt_events_hive/dt=2026-10-03` | 
| `2026-10-04` | `s3://amzn-s3-demo-bucket/tables/alt_events_hive/imports/2026-10-04` | 
| `2026-10-05` | `s3://amzn-s3-demo-bucket/tables/alt_events_hive/dt=2026-10-05` | 
| `2026-10-06` | `s3://amzn-s3-demo-bucket/tables/alt_events_hive/dt=2026-10-06` | 

### Considerations
<a name="athena-duckdb-statement-alter-drop-table-add-partition-considerations"></a>

`ADD PARTITION` works only on Hive tables. An Iceberg table keeps track of its partitions in its own metadata, and `ADD PARTITION` on an Iceberg table fails.

### Differences from Athena engine version 3
<a name="athena-duckdb-statement-alter-drop-table-add-partition-differences-from-engine-version-3"></a>

Athena engine version 3 can register the partition folders under a table location with `MSCK REPAIR TABLE`. DuckDB does not support `MSCK REPAIR TABLE`. Register partitions with `ALTER TABLE` `ADD PARTITION` or with the `glue_repair_table` function.

## `DROP PARTITION`
<a name="athena-duckdb-statement-alter-drop-table-drop-partition"></a>

`ALTER TABLE` `DROP PARTITION` removes one or more partitions of a Hive table from the AWS Glue Data Catalog. Queries of the table no longer read the data files of a removed partition, but the files stay in Amazon S3. To read them again, register the partition again with `ADD PARTITION`.

To remove several partitions in one statement, separate them with commas. With `IF EXISTS`, the statement skips partitions that are not registered. Without `IF EXISTS`, the statement fails if a partition is not registered.

The statement returns one row for each partition that it names, with the columns `action`, `partition`, and `location`. The `location` column is `NULL`. With `IF EXISTS`, a partition that was not registered still has a row in the result.

You can also remove a partition with the `glue_drop_partition` function. For more information about `glue_drop_partition`, see [AWS Glue Data Catalog functions in DuckDB](duckdb-functions-glue.md).

### Syntax
<a name="athena-duckdb-statement-alter-drop-table-drop-partition-syntax"></a>

```sql
ALTER TABLE {{table_name}} DROP [ IF EXISTS ]
    PARTITION ( {{partition_column}} = {{value}} [, ...] )
    [, PARTITION ( {{partition_column}} = {{value}}
        [, ...] ) ... ]
```

In the syntax, replace each placeholder as follows:

**{{partition\_column}}**  
A partition column of the table. Give a value for every partition column of the table.

**{{value}}**  
The value of the partition column for the partition, such as `'2026-10-02'`.

### Examples
<a name="athena-duckdb-statement-alter-drop-table-drop-partition-examples"></a>

The following SQL statement removes the partition `dt = '2026-10-02'`, which holds one event. The location in the result is `NULL`.

```sql
ALTER TABLE sales_db.alt_events_hive DROP PARTITION (
    dt = '2026-10-02'
)
```

The statement returns the following result.


| action | partition | location | 
| --- | --- | --- | 
| `drop partition` | `2026-10-02` | `NULL` | 

The following SQL statement removes the same partition again with `IF EXISTS`. The partition is no longer registered, so the statement succeeds and changes nothing. The result still has a row for the partition.

```sql
ALTER TABLE sales_db.alt_events_hive DROP IF EXISTS PARTITION (
    dt = '2026-10-02'
)
```

The statement returns the following result.


| action | partition | location | 
| --- | --- | --- | 
| `drop partition` | `2026-10-02` | `NULL` | 

The following SQL statement removes two partitions in one statement. The result has one row for each partition.

```sql
ALTER TABLE sales_db.alt_events_hive
DROP PARTITION (
    dt = '2026-10-05'
), PARTITION (dt = '2026-10-06')
```

The statement returns the following results.


| action | partition | location | 
| --- | --- | --- | 
| `drop partition` | `2026-10-05` | `NULL` | 
| `drop partition` | `2026-10-06` | `NULL` | 

The following SQL query lists the partitions that remain. The removed partitions are no longer listed.

```sql
SELECT dt
FROM glue_partitions('sales_db.alt_events_hive')
ORDER BY dt
```

The query returns the following results.


| dt | 
| --- | 
| `2026-10-01` | 
| `2026-10-03` | 
| `2026-10-04` | 

The following SQL query reads the table. The event in the removed `2026-10-02` partition is no longer read.

```sql
SELECT event_id, event, dt
FROM sales_db.alt_events_hive
ORDER BY event_id
```

The query returns the following results.


| event\_id | event | dt | 
| --- | --- | --- | 
| `1` | `signup` | `2026-10-01` | 
| `2` | `login` | `2026-10-01` | 

The following SQL query checks the folder of the removed partition in Amazon S3. Its data files are still there.

```sql
SELECT count(*) > 0 AS files_remain
FROM glob(
    's3://amzn-s3-demo-bucket/tables/alt_events_hive/dt=2026-10-02/*'
)
```

The query returns the following result.


| files\_remain | 
| --- | 
| `true` | 

### Considerations
<a name="athena-duckdb-statement-alter-drop-table-drop-partition-considerations"></a>

`DROP PARTITION` works only on Hive tables. On an Iceberg table, the statement fails.

To delete the data of a removed partition, delete the files at its location in Amazon S3.

## `DROP TABLE`
<a name="athena-duckdb-statement-alter-drop-table-drop-table"></a>

`DROP TABLE` removes a table from the AWS Glue Data Catalog. For a Hive table, the data files stay at the table location in Amazon S3. For an Iceberg table in the AWS Glue Data Catalog, the data files and the metadata files stay there. For a table in Amazon S3 Tables, `DROP TABLE` deletes the data.

With `IF EXISTS`, the statement does nothing if the table does not exist. Without `IF EXISTS`, dropping a table that does not exist fails.

To read the files of a dropped Hive table, pass its location to a reader function such as `read_parquet`. To delete the data, delete the files under the table location in Amazon S3.

To drop a view, use `DROP VIEW`. For more information about views, see [Work with views](duckdb-views.md).

### Syntax
<a name="athena-duckdb-statement-alter-drop-table-drop-table-syntax"></a>

```sql
DROP TABLE [ IF EXISTS ] {{table_name}}
```

### Examples
<a name="athena-duckdb-statement-alter-drop-table-drop-table-examples"></a>

The following SQL statement drops the Hive table `alt_old_orders_hive`.

```sql
DROP TABLE sales_db.alt_old_orders_hive
```

The statement returns no rows.

The following SQL query checks that the table no longer exists. No table with that name is left.

```sql
SELECT count(*) AS matching_tables
FROM duckdb_tables()
WHERE schema_name = 'sales_db'
    AND table_name = 'alt_old_orders_hive'
```

The query returns the following result.


| matching\_tables | 
| --- | 
| `0` | 

The following SQL query reads the data files that the dropped table left in Amazon S3. They still hold its three orders.

```sql
SELECT count(*) AS orders
FROM read_parquet(
    's3://amzn-s3-demo-bucket/tables/alt_old_orders_hive/*'
)
```

The query returns the following result.


| orders | 
| --- | 
| `3` | 

The following SQL statement drops the table again with `IF EXISTS`. The table no longer exists, so the statement succeeds and changes nothing.

```sql
DROP TABLE IF EXISTS sales_db.alt_old_orders_hive
```

The statement returns no rows.

The following SQL statement drops the Iceberg table `alt_old_orders_iceberg`.

```sql
DROP TABLE sales_db.alt_old_orders_iceberg
```

The statement returns no rows.

The following SQL query lists the folders under the location of the dropped Iceberg table that still hold files. Both the `data` folder and the `metadata` folder still hold files.

```sql
SELECT DISTINCT
    regexp_extract(
        file, 'alt_old_orders_iceberg/([^/]+)/', 1
    ) AS folder
FROM glob(
    's3://amzn-s3-demo-bucket/tables/alt_old_orders_iceberg/**'
)
ORDER BY folder
```

The query returns the following results.


| folder | 
| --- | 
| `data` | 
| `metadata` | 

### Considerations
<a name="athena-duckdb-statement-alter-drop-table-drop-table-considerations"></a>

A Hive table that you create at the location of a dropped table reads the files that the dropped table left there as its own rows. A `CREATE TABLE AS SELECT` statement for a Hive table fails when its location still holds data files. To use the location for a new Hive table, first delete its files.

### Differences from Athena engine version 3
<a name="athena-duckdb-statement-alter-drop-table-drop-table-differences-from-engine-version-3"></a>

In Athena engine version 3, `DROP TABLE` on an Iceberg table in the AWS Glue Data Catalog deletes the data files and metadata files of the table from Amazon S3. In DuckDB, those files stay in Amazon S3.