# How to Export Data from Dolt: Complete Guide to Table and Schema Export

> Learn how to export data from Dolt. Use `dolt table export` for data and `dolt schema export` for DDL with this complete guide.

- Repository: [DoltHub/dolt](https://github.com/dolthub/dolt)
- Tags: how-to-guide
- Published: 2026-03-14

---

**Dolt provides two primary CLI commands for exporting data: `dolt table export` for row data (CSV, JSON, Parquet, etc.) and `dolt schema export` for DDL statements, both leveraging a pluggable mvdata pipeline architecture.**

Dolt is a version-controlled SQL database that combines Git-like versioning with MySQL-compatible tables. When you need to extract data from a `dolthub/dolt` repository for analysis, migration, or backup purposes, the CLI offers robust export capabilities backed by a sophisticated data movement pipeline written in Go. This guide explains how to export both table rows and schema definitions using the official source code as reference.

## Dolt Export CLI Commands Overview

Dolt separates data export into two distinct commands based on what you need to extract:

- **`dolt table export`** – Exports the **rows** of a table to various formats including CSV, PSV, JSON, JSONL, SQL, and Parquet
- **`dolt schema export`** – Exports the **DDL** (CREATE TABLE statements) for one or all tables

Both commands share a common architecture built on Dolt’s **mvdata** (move-data) package, providing consistent argument parsing, format detection, and streaming data movement.

## How `dolt table export` Works

The `dolt table export` command, implemented in [`go/cmd/dolt/commands/tblcmds/export.go`](https://github.com/dolthub/dolt/blob/main/go/cmd/dolt/commands/tblcmds/export.go), follows a pipeline architecture that streams data from the Dolt storage engine to your chosen destination.

### Command Syntax and Flags

The basic syntax follows this pattern:

```bash
dolt table export [-f] [--file-type <type>] <table> <file>

```

Key parameters include:
- **`-f`** – Force overwrite of existing files (skips the `checkOverwrite` validation)
- **`--file-type`** – Explicitly set the format when the file extension is ambiguous
- **`<table>`** – The source table name in the current database
- **`<file>`** – Destination path, or `-` for stdout streaming

### The Export Pipeline Architecture

According to the source code in [`tblcmds/export.go`](https://github.com/dolthub/dolt/blob/main/tblcmds/export.go), the export process follows these steps:

1. **Argument parsing** – The command builds an `argparser.ArgParser` that validates flags such as `-f` and `--file-type` (lines 78‑86)
2. **Destination resolution** – The user-supplied path and optional `--file-type` are turned into a `mvdata.DataLocation` via `mvdata.NewDataLocation`. This object determines the output format and whether the destination is a regular file or a stream (lines 98‑108)
3. **Overwrite protection** – If `-f` is omitted, `exportOptions.checkOverwrite` verifies whether the destination exists and aborts with an error (lines 65‑73)
4. **SQL engine setup** – A temporary SQL engine (`engine.NewSqlEngineForEnv`) initializes to read the table’s rows (lines 92‑104)
5. **Reader creation** – `mvdata.NewSqlEngineReader` builds a row reader that streams rows from the selected table (line 22)
6. **Writer creation** – `exportOptions.dest.NewCreatingWriter` produces a format-specific writer backed by either a file handle or `os.Stdout` (lines 66‑72)
7. **Data movement** – `mvdata.NewDataMoverPipeline` wires the reader and writer together; calling `pipeline.Execute()` streams the data from source to destination (lines 32‑35)

This architecture supports **pluggable output formats** including CSV, PSV, JSON, JSONL, SQL, and Parquet.

## How `dolt schema export` Works

The `dolt schema export` command, implemented in [`go/cmd/dolt/commands/schcmds/export.go`](https://github.com/dolthub/dolt/blob/main/go/cmd/dolt/commands/schcmds/export.go), extracts DDL rather than row data.

When you run this command, Dolt iterates over the specified tables (or all non-system tables via `doltdb.GetNonSystemTableNames`) and constructs `CREATE TABLE` statements using `dsqle.GetCreateTableStmt`. The resulting DDL is written sequentially to the specified file path or stdout.

Key implementation details from [`schcmds/export.go`](https://github.com/dolthub/dolt/blob/main/schcmds/export.go) include:
- Argument parsing occurs at lines 65‑70
- Schema extraction logic at lines 92‑55
- Supports both single-table and full-database export modes

## Practical Export Examples

### Exporting Table Data to CSV

Export the "users" table to a CSV file (format inferred from extension):

```bash
dolt table export users users.csv

```

Under the hood, this creates a `DataLocation` with format `CsvFile`, builds a SQL reader for the `users` table, and streams rows to the file.

### Exporting to JSON Lines with Force Overwrite

Export the "orders" table to JSONL format, overwriting if the file exists:

```bash
dolt table export -f --file-type jsonl orders orders.jsonl

```

The `-f` flag bypasses the overwrite check, while `--file-type jsonl` forces the format when the extension might be ambiguous.

### Streaming to Standard Output

Export data directly to stdout for piping into other tools:

```bash
dolt table export -f mytable -

```

When the destination is `-`, the command creates a `mvdata.StreamDataLocation` that writes CSV (default) directly to `stdout`. Note that only CSV and PSV formats support streaming.

### Exporting Schema DDL

Generate the CREATE TABLE statement for a specific table:

```bash
dolt schema export products products_schema.sql

```

This calls `dsqle.GetCreateTableStmt` for the "products" table and writes the DDL to the specified file.

### Exporting All Schemas

Export DDL for all non-system tables in the database:

```bash
dolt schema export all_schemas.sql

```

With no table argument provided, Dolt iterates over all tables and writes each `CREATE TABLE` statement sequentially.

### Exporting to Parquet Format

Export table data to Apache Parquet (experimental support):

```bash
dolt table export --file-type parquet mytable mytable.parquet

```

The mvdata pipeline recognizes Parquet as a valid format type and instantiates the appropriate writer via `NewCreatingWriter`.

## Key Implementation Files

Understanding these source files helps when building custom tools or debugging export behavior:

- **[`go/cmd/dolt/commands/tblcmds/export.go`](https://github.com/dolthub/dolt/blob/main/go/cmd/dolt/commands/tblcmds/export.go)** – Implements `dolt table export` including argument parsing, destination handling, and pipeline orchestration (lines 78‑108, 32‑35)
- **[`go/cmd/dolt/commands/schcmds/export.go`](https://github.com/dolthub/dolt/blob/main/go/cmd/dolt/commands/schcmds/export.go)** – Implements `dolt schema export` for DDL extraction (lines 65‑70, 92‑55)
- **[`go/libraries/doltcore/mvdata/data_loc.go`](https://github.com/dolthub/dolt/blob/main/go/libraries/doltcore/mvdata/data_loc.go)** – Defines `DataLocation`, format inference logic, and writer factories used by both export commands
- **[`go/libraries/doltcore/mvdata/data_loc_test.go`](https://github.com/dolthub/dolt/blob/main/go/libraries/doltcore/mvdata/data_loc_test.go)** – Unit tests illustrating supported formats (`csv`, `psv`, `json`, `jsonl`, `parquet`)

## Summary

- Dolt provides **two export commands**: `dolt table export` for row data and `dolt schema export` for DDL
- The **mvdata package** provides a unified pipeline architecture using `DataLocation`, `NewSqlEngineReader`, and `NewDataMoverPipeline`
- Supported export formats include **CSV, PSV, JSON, JSONL, SQL, and Parquet**
- Use the **`-f` flag** to force overwrite existing files
- Export to **stdout** using `-` as the destination (CSV and PSV only)
- Schema export uses **`dsqle.GetCreateTableStmt`** to generate standard SQL DDL

## Frequently Asked Questions

### Does Dolt support exporting to Parquet format?

Yes, Dolt supports Apache Parquet export via `dolt table export --file-type parquet <table> <file>`. The mvdata pipeline in [`go/libraries/doltcore/mvdata/data_loc.go`](https://github.com/dolthub/dolt/blob/main/go/libraries/doltcore/mvdata/data_loc.go) recognizes Parquet as a valid format type and instantiates the appropriate binary writer. This feature is marked as experimental in current versions.

### Can I export Dolt data to standard output for piping?

Yes, specify `-` as the destination file to stream output to stdout: `dolt table export mytable -`. Only CSV and PSV formats support streaming via `mvdata.StreamDataLocation`. This is useful for piping data directly into other command-line tools without creating intermediate files.

### What is the difference between `dolt table export` and `dolt schema export`?

`dolt table export` extracts the actual row data from tables into formats like CSV or JSON, while `dolt schema export` extracts only the DDL (CREATE TABLE statements) defining the table structures. The former uses `mvdata.NewSqlEngineReader` to stream rows, whereas the latter calls `dsqle.GetCreateTableStmt` to generate SQL definitions.

### How do I force overwrite an existing export file?

Add the `-f` or `--force` flag to your export command. Without this flag, the `exportOptions.checkOverwrite` function in [`tblcmds/export.go`](https://github.com/dolthub/dolt/blob/main/tblcmds/export.go) (lines 65‑73) checks if the destination file exists and aborts with an error to prevent accidental data loss. The `-f` flag bypasses this safety check.