Tutorial

How to Open & Query a DuckDB Database: Step-by-Step Tutorial

By FinancialDataTools.com Team  ·  March 2026  ·  9 min read  ·  Last updated March 14, 2026

🦆 Open the DuckDB Viewer and follow along with this tutorial.

Open Tool →

Steps

  1. Locate Your DuckDB File
  2. Open the DuckDB Viewer
  3. Load Your Database
  4. Browse Tables
  5. Sort and Filter Rows
  6. Run a SQL Query
  7. Inspect the Schema
  8. Export Your Data

This tutorial walks you through opening, querying, and exporting a DuckDB database using the free FinancialDataTools.com DuckDB Viewer. The tool uses DuckDB-Wasm — the official WebAssembly build of the DuckDB analytical engine — to run entirely inside your browser. Nothing is sent to any server.

Try the DuckDB Viewer — runs entirely in your browser and never uploads your files.

Open the DuckDB Viewer →

Step 1: Locate Your DuckDB File

Find the .duckdb or .db file you want to inspect. DuckDB databases are created by the DuckDB engine and appear in a variety of data engineering and analytics contexts:

The viewer works with DuckDB-native database files. SQLite databases should be opened in the SQLite Viewer; Parquet files should be opened in the Parquet Viewer.

Step 2: Open the DuckDB Viewer

Navigate to financialdatatools.com/viewers/duckdb-viewer/ in any modern desktop browser (Chrome, Firefox, Edge, or Safari). No login, account, or installation is required. The viewer works best on desktop.

Step 3: Load Your Database

There are two ways to open your database:

Loading happens in three stages, each shown with a status message:

  1. Initialising DuckDB-Wasm — the DuckDB engine loads into the browser (first load only; cached for subsequent files)
  2. Reading Parquet metadata — the database schema is read without loading row data
  3. Loading rows — the first page of rows is fetched

Once loaded, the tab bar shows a tab for each table in your database, and the stats bar shows the total row count, visible rows, column count, and the current table name.

Step 4: Browse Tables

Click any tab to switch between tables. The data grid shows your rows in a spreadsheet-style layout. Each column header displays:

Click any cell to open the Cell Detail Panel on the right, which shows the full untruncated value. Nested types (LIST, STRUCT, MAP) are displayed as formatted JSON in the detail panel.

Step 5: Sort and Filter Rows

Sorting: Click any column header to sort. First click: ascending. Second: descending. Third: original order.

Global search: Type in the search box in the toolbar to search across all visible columns. Results update in real time.

Column filters: Click the filter icon in any column header. Two modes:

Column filters operate on the currently loaded page. For filtering across millions of rows in a large database, use the SQL panel in Step 6 with a WHERE clause instead.

Step 6: Run a SQL Query

The SQL panel is the most powerful feature of the DuckDB Viewer. Click the amber SQL button in the toolbar to open it. The panel contains a resizable multi-line text editor.

Type any DuckDB SELECT statement and press Ctrl+Enter (or Cmd+Enter on Mac), or click the ▶ Run button. The results replace the current table view in the grid.

A few example queries to get you started:

Preview the first 100 rows of a table:

SELECT * FROM my_table LIMIT 100;

Filter rows and select specific columns:

SELECT trade_date, symbol, quantity, price
FROM trades
WHERE trade_date >= '2025-01-01'
  AND symbol = 'AAPL'
ORDER BY trade_date DESC;

Aggregate data:

SELECT
  symbol,
  COUNT(*) AS num_trades,
  SUM(quantity * price) AS total_notional,
  AVG(price) AS avg_price
FROM trades
GROUP BY symbol
ORDER BY total_notional DESC;

Window function — rolling average:

SELECT
  trade_date,
  close_price,
  AVG(close_price) OVER (
    ORDER BY trade_date
    ROWS BETWEEN 19 PRECEDING AND CURRENT ROW
  ) AS ma_20d
FROM prices
WHERE symbol = 'SPY'
ORDER BY trade_date;

After running a query, the results appear in the grid with the same sorting, filtering, column detail, and export capabilities as the regular table view. The status line below the editor shows the number of rows returned.

Any SQL syntax errors or runtime errors are displayed in red below the Run button.

Step 7: Inspect the Schema

Click the Schema button in the toolbar to open the column schema modal for the active table (not available in SQL query mode). It shows each column's name and full DuckDB type string, derived from a DESCRIBE query. Use Copy Schema to copy the column list as plain text.

Step 8: Export Your Data

Click the Export button in the toolbar to open the export dialog. Four formats are available:

Three export scopes let you control the data exported:

Tip: Use the All tables Excel export to convert an entire DuckDB database into a multi-sheet workbook that you can share with stakeholders who don't have DuckDB installed.

Related Articles

Advertisement