---
title: Export a table or a result
project: TotalSQL
version: Latest
section: guides
language: en
license: 
url: https://totaljs.es/docs/totalsql/latest/guides/export/
updated: 2026-12-02T15:40:26.075Z
---

# Export a table or a result

> Save the rows of a table, or the result of a query, to a file for a spreadsheet, for a program or for another database.

## Export a table

1. Open the table, and filter or sort it if you want.
2. Press **Export the table…**, the arrow at the bottom.
3. Choose the **Format**, and press **Choose where…**

Every row that passes your filters is written, not only this page, in the order that you chose. Changes not saved do not go into the file. Views are exported in the same way.

While a large table is written, the rest of that connection waits.

## Export a result

In a query, press **Export…** above the result. If the query returned more rows than the result keeps, only those kept are written, and the dialog says so. To have them all, export the table or a view.

To paste a result in a spreadsheet without a file, press **Copy the result, to paste in a spreadsheet**.

## The formats

| Format | What it is | From |
| --- | --- | --- |
| **CSV** | Commas, in UTF-8, with the names of the columns in the first line | Tables and results |
| **CSV for Excel** | The same, with the mark that Excel needs to read accents | Tables and results |
| **JSON** | A list with an object for each row | Tables and results |
| **SQL (INSERT statements)** | An `INSERT` for each row, in the dialect of the database | Tables |

## How values are written

- In CSV, NULL is an empty field, and an empty text is `""`, so you can tell them apart.
- In JSON, numbers keep all their digits, yes and no are `true` and `false`, and the JSON of a column goes in as JSON.
- Binary values are written in hexadecimal.
- In `INSERT` statements, the columns that the database computes are left out.

The separator of both CSV formats is the comma. If your spreadsheet expects another one, import the file and choose the comma there.

## If it fails

The file takes its place only when it is complete. If an export fails, there is no half file, and one with the same name stays as it was.

## A whole database

To take all the tables with their structure, [make a copy of the database](/totalsql/latest/guides/copy-a-database/).
