

# Run your first query using the console

This quickstart walks you through running your first DuckDB query in the Athena console. You create a DuckDB workgroup, create a database and a table, add rows, query them, and then clean up.

**Note**  
You are charged for the queries that you run in this walkthrough. To avoid ongoing charges, complete the cleanup step at the end.

## Prerequisites
<a name="athena-duckdb-getting-started-console-prerequisites"></a>
+ Use an AWS Region where DuckDB is available. For more information, see [Regions and availability](duckdb-availability.md).
+ Have permission to create workgroups and run queries. For more information, see [Security and permissions](duckdb-permissions.md).
+ Have an Amazon S3 bucket for the table data. In this walkthrough, replace `amzn-s3-demo-bucket` with the name of your bucket.

## Step 1: Create a DuckDB workgroup
<a name="athena-duckdb-getting-started-console-create-workgroup"></a>

**To create a DuckDB workgroup**

1. Open the Athena console at [https://console.aws.amazon.com/athena/](https://console.aws.amazon.com/athena/home).

1. In the console navigation pane, under **Administration**, choose **Workgroups**.

1. Choose **Create workgroup**.

1. For **Workgroup name**, enter a name, such as **my-duckdb-workgroup**.

1. Under **Athena engine version**, for **Engine version**, choose **DuckDB**.

1. Keep the default query result settings. Athena stores the results of DuckDB queries in managed query results, so you don't need a query result location in Amazon S3.

1. Choose **Create workgroup**.

For more information about workgroup settings, see [Workgroups and query controls](duckdb-workgroups.md).

## Step 2: Open the query editor
<a name="athena-duckdb-getting-started-console-open-editor"></a>

**To open the query editor with your workgroup**

1. In the console navigation pane, choose **Query editor**.

1. For **Workgroup**, choose the workgroup that you created in Step 1.

1. For **Data source**, choose **AwsDataCatalog**.

Each query runs one statement. To run each statement in the following steps, enter it in the query editor and then choose **Run**.

## Step 3: Create a database and a table
<a name="athena-duckdb-getting-started-console-create-table"></a>

Run the following statement to create a database. In DuckDB, a database is a schema.

```sql
CREATE SCHEMA duckdb_quickstart
```

Run the following statement to create a table in the AWS Glue Data Catalog. The `WITH` clause sets the table type, file format, and data location.

```sql
CREATE TABLE duckdb_quickstart.sales (
    order_id INTEGER,
    customer VARCHAR,
    region VARCHAR,
    amount DECIMAL(10,2),
    order_date DATE
)
WITH (
    type = 'HIVE',
    format = 'parquet',
    location = 's3://{{amzn-s3-demo-bucket}}/duckdb-quickstart/sales/'
)
```

## Step 4: Add rows
<a name="athena-duckdb-getting-started-console-add-rows"></a>

Run the following statement to add rows to the table.

```sql
INSERT INTO duckdb_quickstart.sales VALUES
    (1, 'alice', 'east', 120.50, DATE '2026-10-01'),
    (2, 'bob', 'west', 75.00, DATE '2026-10-01'),
    (3, 'carol', 'east', 42.25, DATE '2026-10-02')
```

## Step 5: Query the table
<a name="athena-duckdb-getting-started-console-query"></a>

Run the following query. The results appear on the **Query results** tab below the editor.

```sql
SELECT region, count(*) AS order_count, sum(amount) AS revenue
FROM duckdb_quickstart.sales
GROUP BY ALL
ORDER BY region
```

`GROUP BY ALL` is DuckDB syntax. It groups by every column in the select list that isn't an aggregate. For more SQL, see [SQL reference](duckdb-sql-reference.md).

## Step 6: Clean up
<a name="athena-duckdb-getting-started-console-clean-up"></a>

To avoid incurring additional charges, delete the resources that you created in this walkthrough.

**To clean up**

1. Run the following statement to delete the database and its table. `DROP` removes only the catalog entries. The data files stay in Amazon S3.

   ```sql
   DROP SCHEMA duckdb_quickstart CASCADE
   ```

1. In the Amazon S3 console, delete the `duckdb-quickstart/` folder from your bucket.

1. In the Athena console navigation pane, under **Administration**, choose **Workgroups**.

1. Select your workgroup. Choose **Actions**, and then choose **Delete**. Confirm the deletion.

## Next steps
<a name="athena-duckdb-getting-started-console-next-steps"></a>

Now that you have run your first DuckDB query, learn more in the following topics:
+ [SQL reference](duckdb-sql-reference.md)
+ [Workgroups and query controls](duckdb-workgroups.md)
+ [Migrate from Athena engine version 3 to DuckDB](duckdb-migration-agent.md)