> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tablepro.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Import & Export

> Export to CSV, JSON, SQL, MQL, XLSX, or a data dictionary. Import SQL, JSON, and CSV files with column mapping and transaction safety

**File > Export** (`Cmd+Shift+E`) re-reads every table you tick with `SELECT * FROM`, so what is on screen has no bearing on the file: filters, sort, hidden columns, and the page you are on are all ignored, and table size does not matter. **File > Export > Export Results…** (`Cmd+Option+Shift+E`), also on the grid's right-click menu, writes what the tab has loaded instead. **File > Export > Export Data Dictionary…** describes the tables rather than their rows. Import is `Cmd+Shift+I`.

## Export data

**1. Open the export dialog**

Open a table or run a query, then choose **File > Export** (`Cmd+Shift+E`). To export only the rows the tab holds, press `Cmd+Option+Shift+E` or right-click the results grid and choose **Export Results…**.

**2. Choose a format and scope**

Pick a format, tick objects in the tree, and set the options for that format.

**3. Export**

Click **Export**. The destination file appears only on success: a failed or cancelled export removes its partial file.

The last format and its options come back next time, but only after an export succeeds; cancelling discards the changes. **Reset to Defaults** restores the stock settings for the current format.

The bookmark button above the tree saves the current selection under a name and reapplies it later, including each table's options and row filter. A saved selection naming tables the database no longer has says how many it still matches, and applying it selects those and clears the rest.

![Export dialog](https://mintcdn.com/ngquct/tXWaltqW4Zqkau0T/images/export-dialog.png?fit=max\&auto=format\&n=tXWaltqW4Zqkau0T\&q=85\&s=88f6b416531c585af347e8a262df3ec6)

Export dialog

### What the tree lists

SQL exports more than tables. A database holding more than one kind of object groups them, in the order a restore needs them:

| Group | Written as | Engines |
| - | - | - |
| Types | `CREATE TYPE` | PostgreSQL and its forks |
| Sequences | `CREATE SEQUENCE` | PostgreSQL and its forks |
| Tables | `CREATE TABLE` plus `INSERT` and `CREATE INDEX` | every SQL engine |
| Foreign Tables | `CREATE FOREIGN TABLE` | PostgreSQL |
| Views | `CREATE VIEW` from the server's own definition | every SQL engine |
| Materialized Views | `CREATE MATERIALIZED VIEW` | PostgreSQL, Oracle |
| Routines | `CREATE FUNCTION` or `CREATE PROCEDURE` | engines with stored routines |
| Triggers | `CREATE TRIGGER` | engines with triggers |
| Events | `CREATE EVENT` | MySQL, MariaDB |
| Privileges | `GRANT`, one principal per row | engines with user management |

An Oracle or Dameng routine or trigger is followed by a `/` line, and a MySQL or MariaDB routine, trigger or event with a body sits in a `DELIMITER` block, the same form a [saved sync script](https://docs.tablepro.app/features/compare-sync.md#the-script) uses. Restore those dumps with SQL\*Plus, DISQL or the `mysql` client. A SQL Server dump ends every statement with a `GO` line, so each one runs as its own batch in `sqlcmd` and SQL Server Management Studio.

A database with only tables lists them flat, with no group to open first.

On an engine that groups by database, each database is listed from what the server says it holds. One the account can list but not open is left out, so the rest of the tree still opens.

On an engine that groups by schema, the tree lists the schemas the sidebar's [schema filter](https://docs.tablepro.app/features/connection-window.md#filtering-schemas) keeps, plus the schema you are browsing, the default schema (`public` on PostgreSQL), the schema of each table you opened the dialog on, and every schema a saved selection names. Right-click a database or schema and choose **Export…** to list every schema it covers, filter or not.

The default schema and the schemas of the tables you opened the dialog on open expanded, and the rest collapsed. A collapsed schema lists its tables and views only: expand it, or select its checkbox, to read its routines, triggers, sequences and types. **Export** is dimmed until they arrive. A database or schema exported with **Export…** is read in full from the start.

Arrow keys move through the tree, Left and Right close and open a group, and Space ticks every selected row, or unticks them when all are ticked. Ticking a group ticks everything under it except an object whose option columns are all off.

Only SQL writes every group. CSV, JSON and XLSX take tables and views, and switching to one of them drops the rest from the tree. Per-object checkboxes follow the kind: **Data** is off the row for anything without rows, and a privilege row carries neither **Drop** nor **Data**.

> [!WARNING]
>
> Privileges are server-wide, so they appear once, under the container the dialog opened on. A `GRANT` naming an object the dump does not create fails on restore.

### Narrowing what a table exports

Click the filter icon on a table row to write a `WHERE` clause, cap the row count, or pick columns. The icon fills in once a table is narrowed, and its tooltip repeats what the narrowing is.

The clause is your engine's own SQL, spliced into the `SELECT` the export runs. It has to be one expression: a semicolon anywhere but the end refuses the filter, and the export summary says the table went out whole.

Ticking no column exports every column, which is also what a table with a column added later gets.

### What ends up in the file

A whole-table export streams from the database at constant memory, with no row-count limit, and can be stopped from the progress the export sheet shows while it runs.

**Export Results…** writes what the tab holds in memory, which is the output of the query that filled it. The filter bar and a sorted header are part of that query, and so is column visibility on a table tab: hiding a column re-queries without it, keeping only the primary key and anything being sorted on. Two things are not part of it. A column value filter narrows the loaded rows in the grid afterwards, so it never reaches the file. And a truncated result with more rows behind it is re-run and streamed in full rather than written as far as it got.

As SQL, a results export writes `INSERT` statements only. A result set is the output of a query rather than a table, so there is no schema to recreate and nothing to drop: the **Structure** and **Drop** options belong to **File > Export**, which reads real tables. Identifiers are quoted and values escaped the way the source engine reads them, so the file imports back into it.

### Formats

> [tab] CSV
>
> | Option | Default |
> | - | - |
> | Header row | Yes |
> | Delimiter (comma, semicolon, tab, pipe) | Comma |
> | Quote handling (always, as needed, never) | As needed |
> | NULL to empty strings | Yes |
> | Line breaks in values to spaces | No |
> | Line ending (LF, CRLF, CR) | LF |
> | Decimal separator (period, comma) | Period |
> | Sanitize formula-like values | No |
> | Encoding (UTF-8, ISO Latin 1, Windows-1252) | UTF-8 |
> | Include byte order mark | No |
>
> Sanitizing prefixes a value starting with `=`, `+`, `-`, or `@` with a single quote, so a spreadsheet treats it as text. A plain number such as `-5` or `+1.5e3` is written as it is. The quote stays in the data for any program that imports the file, so turn it on only for a file meant for a spreadsheet; the export then says how many values it quoted.
>
> Excel on Windows needs the byte order mark to read a UTF-8 file. Readers that do not expect one read it as part of the first column name. Only UTF-8 carries a mark, so the checkbox dims for the other two encodings.
>
> ISO Latin 1 and Windows-1252 cover fewer characters than the data might hold. A character neither can represent is written as `?`, and the export finishes with a warning listing the characters that were dropped.

> [tab] JSON
>
> One object per table, each holding an array of rows.
>
> | Option | Default |
> | - | - |
> | Layout (one JSON object, one row per line) | One JSON object |
> | Pretty print | Yes |
> | Include NULL values | Yes |
> | Preserve all values as strings | No |
>
> **One row per line** writes NDJSON to a `.ndjson` file: no wrapping object, no array, one row per line, so a stream reader can process a file larger than memory a line at a time. Pretty print does not apply to it and is dimmed. Import reads `.json`, `.jsonl` and `.ndjson`, detecting the layout from the file.

> [tab] SQL
>
> | Option | Default |
> | - | - |
> | Compress with gzip (`.sql.gz`) | No |
> | Batch size (rows per INSERT: 1, 100, 500, 1,000) | 500 |
> | Max INSERT size (no limit, 256 KB, 1, 4, 16, 64 MB) | 1 MB |
> | On existing rows (insert, skip, replace, update) | Insert |
> | Split every (one file, 8, 32, 128, 512 MB) | One file |
> | Read every table at one snapshot | No |
> | Exclude the AUTO\_INCREMENT counter | Yes |
> | Exclude DEFINER clauses | Yes |
>
> Structure (CREATE TABLE), Drop (DROP TABLE IF EXISTS), and Data (INSERT statements) are per-table checkboxes, and a multi-table export can mix them. The same columns on a database, schema or group row set that option for everything beneath it, and show a dash when the objects differ. For a schema-only export, tick the database, then untick **Drop** and **Data** on its row.
>
> Structure carries the table's indexes. They are written after the rows and before the deferred foreign keys, the order `pg_dump` uses, so the rows load without index upkeep and a foreign key that references a unique index finds it in place. On MySQL, MariaDB, ClickHouse, Trino and CockroachDB the server writes them inside `CREATE TABLE`, so they arrive with the table instead. A materialized view's indexes follow the view. An invalid PostgreSQL index, which a failed `CREATE INDEX CONCURRENTLY` leaves behind, is left out, as `pg_dump` leaves it out.
>
> On PostgreSQL, Structure carries comments as well. Each table, view and materialized view gets its own `COMMENT ON` and one `COMMENT ON COLUMN` per commented column, directly after its `CREATE`. A foreign table is the exception: its comments are dropped, because the dump writes `CREATE TABLE` for it and PostgreSQL then refuses `COMMENT ON FOREIGN TABLE`. Where the server's own `CREATE TABLE` already carries the comment, MySQL and MariaDB among them, it arrives with the table instead.
>
> > [!WARNING]
> >
> > All three are on by default, so an SQL export carries `DROP TABLE IF EXISTS` unless you untick **Drop**. Run that file against the wrong database and it drops the tables first.
>
> A multi-table export orders the tables by their foreign keys, so a parent is created and filled before the rows that reference it and dropped after them. Foreign keys between two tables that reference each other leave no such order: those tables keep the order the export listed them in, the file says so in a comment, and the summary repeats it. A MySQL or MariaDB dump turns foreign key checks off itself; on other engines, import that one with **Disable foreign key checks** ticked.
>
> The last two exclusions cover MySQL and MariaDB, and pass every other engine through untouched.
>
> An INSERT closes at **Max INSERT size** or at **Batch size**, whichever it reaches first. MySQL and MariaDB treat one statement as one packet and reject anything over `max_allowed_packet`, which a table of wide rows passes long before it reaches 500 rows: 500 rows of a megabyte each is a 524 MB statement, and the server answers `Server has gone away`. The default of 1 MB sits under every `max_allowed_packet` those servers have shipped with, and every other value in the menu is one of those defaults. Choose **No limit** to bound statements by row count alone. A single row wider than the limit cannot be split, so it goes out as a statement of its own that still passes the limit, and the summary names how many did.
>
> The summary reports the largest INSERT the export wrote and how many rows it carried. A figure well under the limit means the row count is what closed the statements; a figure at it means the opposite.
>
> Insert mode is spelled differently on each engine: `INSERT IGNORE` and `REPLACE INTO` on MySQL and MariaDB, `INSERT OR IGNORE` and `INSERT OR REPLACE` on SQLite, `ON CONFLICT` on PostgreSQL. Updating needs a primary key to name as the conflict target. An engine with no spelling for the mode writes plain inserts, and the export summary says which tables that happened to.
>
> Splitting writes `dump.part1.sql`, `dump.part2.sql` and so on, rotating between statements so no part ends mid-`INSERT`. The summary names the first and last part; restore them in order. Each part re-opens the session state its own statements need, so a part restores on its own, `SET IDENTITY_INSERT` on SQL Server included. With gzip on, each part is a gzip file of its own, `dump.part1.sql.gz` and so on, and the split size is the compressed size on disk. A part that cannot be written stops the export, and the error names the parts already on disk, because a rename cannot be taken back.
>
> A dump is UTF-8 and says so in every part, the way the engine's own dump tool does:
>
> | Engine | Each part opens with |
> | - | - |
> | MySQL, MariaDB | `SET NAMES utf8mb4`, `TIME_ZONE='+00:00'`, `FOREIGN_KEY_CHECKS=0` and `SQL_MODE='NO_AUTO_VALUE_ON_ZERO'`, and ends by putting each one back |
> | PostgreSQL, CockroachDB, PGlite | `SET client_encoding = 'UTF8';` |
> | Amazon Redshift | Nothing. Set `PGCLIENTENCODING=UTF8` before restoring it into a database that is not UTF-8 |
>
> `mysql < dump.sql` and `psql < dump.sql` then restore Japanese, emoji and other non-Latin text intact, even into a `LATIN1` or `EUC_JP` database or from a client whose default is Latin 1.
>
> The MySQL lines are the ones `mysqldump` writes. A zero date such as `0000-00-00`, a partial date such as `2020-00-15` and an AUTO\_INCREMENT value of 0 restore as they were, even on a server whose own SQL mode refuses them, and a backslash in a string survives a server set to `NO_BACKSLASH_ESCAPES`. TIMESTAMP values are read and written in UTC, so they restore to the same moment on a server in another time zone. Each procedure, function, trigger and event is created under the SQL mode it was created with on the source, and an event under its time zone too.
>
> A table with a row filter leaves the session's time zone and SQL mode alone, because the filter is written for them. That dump carries no `TIME_ZONE` line, its TIMESTAMP values are in the session's time zone, and its `SQL_MODE` line keeps `ANSI_QUOTES` when the session uses it.
>
> PostgreSQL rows are read with ISO dates, `postgres` intervals and full float precision, whatever `DateStyle`, `IntervalStyle` and `extra_float_digits` the session has.
>
> A dump from an earlier version of TablePro has no `SQL_MODE` line. To restore its zero dates on a strict server, run `SET SESSION sql_mode = 'NO_AUTO_VALUE_ON_ZERO';` in a query tab on that connection before importing it.
>
> One snapshot opens `START TRANSACTION WITH CONSISTENT SNAPSHOT` on MySQL, `BEGIN ISOLATION LEVEL REPEATABLE READ` on PostgreSQL, and a deferred transaction on SQLite. It holds that transaction open for the whole export.
>
> Excluding the counter drops `AUTO_INCREMENT=<n>` from the table options and leaves the column's own `AUTO_INCREMENT` attribute alone. Restoring rows sets the counter one past the highest key in the data, so a source counter that had run ahead of its rows, after deletes or a reset, does not carry over.
>
> Excluding definers drops `DEFINER=user@host` from a view. The account running the import becomes the definer, and `SQL SECURITY` is untouched, so a definer-rights view then runs with that account's privileges. Keep the clause and the import fails with `ERROR 1227 (42000): Access denied; you need (at least one of) the SET USER privilege(s) for this operation` unless the importing account is privileged, and a view that does get created answers `ERROR 1446 (HY000): The user specified as a definer ('…') does not exist` on every query against it. An invoker-rights view still runs as its caller.
>
> Not available on MongoDB or Redis.

> [tab] MQL
>
> MongoDB only. Writes a `.js` file of `insertMany()` calls that runs in `mongosh`, 500 documents per call by default, with per-collection checkboxes for drop, indexes, and data. The database row's checkbox in each column sets it for every collection.
>
> ```javascript theme={null}
> db.users.insertMany([
>   {"_id": {"$oid": "507f1f77bcf86cd799439011"}, "name": "Alice", "age": 30},
>   {"_id": {"$oid": "507f1f77bcf86cd799439012"}, "name": "Bob", "age": 25}
> ]);
> ```
>
> Top-level values keep their type: `ObjectId`, `ISODate`, `BinData` with its real subtype. A typed value nested inside a subdocument or array is written as a string, so re-importing gives you a string where the original held an ObjectId, date, or binary. Export those collections as JSON, or use `mongodump`.
>
> **Indexes** writes each index as a `createIndex()` call and the collection's validator as a `collMod` command. Any other statement in the collection's DDL is left out, and the line `// Skipped a statement that is not an index or a validator` marks where it stood.

> [tab] XLSX
>
> | Option | Default |
> | - | - |
> | Include headers (bold first row) | Yes |
> | NULL as empty cells | Yes |
>
> Each table becomes its own worksheet and numbers are stored as numeric cells. Excel holds 1,048,576 rows a sheet and 32,767 characters a cell: a longer table splits across sheets, and a longer value is cut to fit, with a warning that counts the values cut. Export to CSV to keep long values whole.

> [tab] Markdown
>
> GitHub-flavoured tables.
>
> | Option | Default |
> | - | - |
> | Align columns | Yes |
> | Write each table's name as a heading | Yes |
> | NULL shows as | `NULL` |
>
> Column widths come from the header and the first 200 rows, so a wide value later in a long table is written whole rather than widening every row before it. A pipe or a line break inside a value is neutralised: both would end the cell early.

> [tab] Parquet
>
> Choose **Install Parquet Export…** at the end of the format menu the first time. The item appears once the plugin registry has loaded, which needs a network connection on a fresh install. The plugin downloads, then Parquet is selected. It carries its own copy of DuckDB, which does the encoding, and is too large to ship in the app.
>
> | Option | Default |
> | - | - |
> | Compression (Snappy, Zstd, Gzip, None) | Snappy |
> | Rows per group | 122,880 |
>
> Column types come from the source engine's own declarations, so numbers, dates and booleans arrive as those rather than as strings. A timestamp or time with time zone is written adjusted to UTC, so it keeps the instant it names. A column holding a value that will not convert is written as text, and the export says which column.
>
> > [!WARNING]
> >
> > Parquet holds one table per file. Selecting several writes `dump.users.parquet`, `dump.orders.parquet` and so on beside the name you chose.

> [tab] Data Dictionary
>
> A description of the schema to hand to a reviewer, an analyst or an auditor. **File > Export > Export Data Dictionary…** opens the dialog on this format, with the same tree and saved selections.
>
> | Option | Default |
> | - | - |
> | Write as (Markdown, HTML) | Markdown |
>
> Each table, view, materialized view and foreign table gets a section with its kind and comment, then one row per column: type, nullable, default, primary key, the foreign key it references, and comment. Indexes and foreign keys follow. A column nothing in the file fills is left out, so an engine without comments or foreign keys prints no empty Comment or References column.
>
> Markdown opens with a contents list linking to an anchor per object. HTML is one file with its style inside it and no external assets, and its tables repeat their header on every printed page.
>
> Only the catalog is read, never a row, so an account with metadata access is enough and a large table costs the same as an empty one. MongoDB, Firebase, Bigtable, DynamoDB and SurrealDB do not offer it: their fields come from sampling records, not from a declared schema.

## Transfer to another connection

Right-click tables in the sidebar and choose **Transfer To…** to copy their rows straight into another connection, with no file in between.

**1. Open both connections**

The destination list holds the connections that are already open. A connection that is not open does not appear.

**2. Pick the destination, its database and schema**

On an engine with schemas, **Schema** picks where the rows land. It starts on the source table's schema when the destination has one by that name, otherwise on the schema the destination is browsing. Then tick the tables to copy.

**3. Transfer**

The destination's [Safe Mode](https://docs.tablepro.app/features/safe-mode.md) covers the whole transfer, with one confirmation and one Touch ID prompt where its level asks for them. Each table is wrapped in its own transaction by default, so a table that fails leaves its own rows untouched and the ones before it committed.

Rows only, into a destination table that already exists. A per-table row filter set in the export tree is not carried over; narrow the transfer by transferring fewer tables. Between two MySQL or MariaDB databases, zero dates, AUTO\_INCREMENT values of 0 and TIMESTAMPs arrive as they were on the source, unless a table has a row filter.

> [!WARNING]
>
> **Delete existing rows first** empties each destination table before writing. There is no undo.

### Column mapping

Each ticked table shows how many of its columns map. Columns match by name, the same spelling first and then the same name in another case. Click the count to point a column at a different destination column, or pick **Skip** to leave it out. **Match by Name** puts every column back.

A destination column takes one source column. Map a second column onto it and **Transfer** stays off until one of the two moves or is skipped.

## Clipboard paste (CSV/TSV)

Select a row in the data grid and press `Cmd+V` to paste tabular data straight in. Tabs parse as TSV, commas as CSV.

## Import data

**File > Import > Import Data…** (`Cmd+Shift+I`) takes `.sql` and `.sql.gz` files, whose statements execute directly against the database, and `.json`, `.jsonl`, `.ndjson`, `.csv`, `.tsv`, and `.xlsx` files, which load into a table you pick or one TablePro creates.

The extension picks the format, so one command covers all of them. A file no format reads is refused in the file panel, which names the extensions this connection takes. Only a SQL dump is read compressed here. To import a `.csv.gz`, open it as a [data file](https://docs.tablepro.app/features/data-files.md) and choose **Edit > Data > Import into Table…**, which also carries any edits you made first.

**File > Import > Import Data From** beside it names the format instead and offers every file, which is the route for a CSV saved as `orders.txt` or with no extension at all. **Actions** in the toolbar carries the same pair.

**1. Pick the file**

Choose **File > Import > Import Data…** and select the file. The sheet that opens depends on what you picked. Select several files, or a folder, to [import them together](#import-several-files).

**2. Set the options**

Encoding, transaction wrapping, and error handling for SQL; parsing and column mapping for CSV and JSON. TablePro remembers the options from your last successful import, and **Reset to Defaults** restores the stock ones.

**3. Review and import**

Check the preview and file size, then click **Import**. The progress bar of a SQL file follows how much of the file has been read, compressed bytes for a `.sql.gz`, and the count beside it counts the statements run so far. The connection's [Safe Mode](https://docs.tablepro.app/features/safe-mode.md) asks once for the whole file where its level calls for a confirmation or Touch ID.

![Import dialog](https://mintcdn.com/ngquct/tXWaltqW4Zqkau0T/images/import-dialog.png?fit=max\&auto=format\&n=tXWaltqW4Zqkau0T\&q=85\&s=5f62beb83de1b8355e3048b5d87c28e3)

Import dialog with SQL file preview

### Options

| Option | What it does | Default |
| - | - | - |
| On error | Stop and Rollback, Stop and Commit, or Skip and Continue | Stop and Rollback |
| Encoding | UTF-8, UTF-16, UTF-16 LE, UTF-16 BE, Latin-1, Windows-1252, ASCII, Shift JIS, EUC-JP, GB 18030, Big5, or EUC-KR | UTF-8 |
| Wrap in transaction | Starts an import transaction when the connection has none. An existing transaction stays under your control. Dimmed in Skip and Continue | Yes |
| Disable foreign key checks | Suspends constraint checks for the import | Yes |

| Mode | What happens on a failed statement |
| - | - |
| **Stop and Rollback** | Stops there and rolls back the transaction the import still controls. Changes outside that transaction can stay |
| **Stop and Commit** | Stops there and commits the transaction the import still controls. A failed transaction can only roll back |
| **Skip and Continue** | Logs it and carries on, including a line the parser cannot read. No import transaction |

Keep the default **Stop and Rollback** unless you want to retain partial work or continue past errors. These options handle errors; clicking **Stop** asks separately what to do with the work already done.

Rollback does not undo changes already committed, writes to nontransactional tables, or other effects the database cannot roll back. For example, MySQL and MariaDB `CREATE`, `ALTER`, and `DROP` statements can commit earlier work. Review the result before retrying a file.

**UTF-16** reads the byte order from the mark at the start of the file and falls back to big-endian, which is what a file with no mark means. Pick **UTF-16 LE** or **UTF-16 BE** for a file that has no mark and is not big-endian. Latin-1 and Windows-1252 differ over the bytes `0x80` to `0x9F`: a dump written by MySQL keeps its curly quotes, en dashes and euro sign there, so Windows-1252 is the one to pick for it.

When the preview cannot read the file in the chosen encoding, the dialog switches to the encoding the dump declares in its `SET NAMES` or `SET client_encoding`, or else to the encoding the text matches. It picks Shift JIS, GB 18030 or Big5 only when the dump declares it, because a byte in those encodings can hide a quote's escaping backslash; choose one by hand for a script that declares nothing. A switch the dialog made is not remembered for the next import. A dump read in any encoding but UTF-8 or ASCII reaches the server as UTF-8, so its `SET NAMES cp932` or `SET client_encoding = 'SJIS'` does not run as written: MySQL and MariaDB keep the connection's own character set, and PostgreSQL gets `SET client_encoding = 'UTF8'`. On MySQL and MariaDB, a `_binary` value in a Latin-1 or Windows-1252 dump is sent as the bytes it held. Any other non-UTF-8 dump stops at a `_binary` value holding non-ASCII bytes, since those cannot be read back exactly; export it with `--hex-blob` instead.

The import runs on the connection's own session, and afterwards puts back the session settings a dump changes: on MySQL and MariaDB the SQL mode, time zone, character set, `autocommit` and the foreign key and unique checks; on PostgreSQL the ones `pg_dump` sets, `search_path` among them. A file that stopped early with `autocommit` off while a transaction is still open keeps `autocommit` off, so commit or roll back that transaction yourself.

On PostgreSQL with **Wrap in transaction** on, `INSERT`, `UPDATE`, `DELETE`, `CREATE`, `ALTER`, `DROP`, `COMMENT`, `GRANT`, `REVOKE` and `TRUNCATE` statements go to the server together, up to 200 statements or 4 MiB at a time, so a dump over a slow link waits one round trip per batch instead of one per statement. A failure still stops at its own line, and nothing after it runs. Every other statement, and any statement holding a backslash, runs on its own. When a statement sent with others changes `standard_conforming_strings`, through a function that calls `set_config`, the import stops at the next statement it had already read, because that statement may end somewhere else under the new setting. Import that file with **Wrap in transaction** off.

On SQL Server a file that holds a `GO` line runs a batch at a time, cut at its `GO` lines the way `sqlcmd` cuts it, so every count and failure here is a batch rather than a statement. A file with no `GO` line runs a statement at a time. See [Scripts and batches](https://docs.tablepro.app/databases/mssql.md#scripts-and-batches).

On PostgreSQL, CockroachDB and KingbaseES the rows after a `COPY ... FROM STDIN`, the form `pg_dump` writes table rows in by default, load through the server's copy protocol inside the import's transaction, read from the file as they are sent. They run up to the line holding only `\.`, which is not sent, and never run as SQL. Text and CSV rows load. Binary rows cannot come from a file, so that `COPY` fails with no rows sent. The line under the progress bar counts the rows sent. **Stop** ends the `COPY` at once, with none of its rows loaded, and stops the import as a failed statement would: no **Stop Import?** question, and the import's own transaction rolls back. A transaction you opened yourself is left failed, so roll it back. On Redshift and PGlite, which cannot take rows this way, the file stops at the `COPY` before sending it, and the error names its line: dump it again with `pg_dump --inserts`. The `\restrict` and `\unrestrict` lines a current `pg_dump` writes run nothing. On MySQL and MariaDB a `DELIMITER` line is read as the `mysql` client reads it: only as the first thing on its line, before any statement text.

SQL Server SQL imports do not automatically commit or roll back after a file batch runs, even with **Wrap in transaction** selected and even without a `GO` line. A batch can change which transaction is open. Read the completion message: if a transaction remains open, commit or roll it back on this connection. This also applies after a successful import. Imports into a selected table from CSV, JSON, or XLSX use the row-import transaction options instead.

Skip and Continue collects up to 1,000 failures with their line numbers and messages, and the summary counts successes against failures behind a **Copy Details** button. **Save Report…** writes them all to a CSV with a line, a statement and the database's own error per row, so a large import's failures can be sorted and searched rather than scrolled. An error that stops the import shows the line, the database's own message, and the failing statement in the import sheet, where **Back** returns to the file and its options for a changed setting and another run. The result shows the first 10,000 characters of a longer statement and the first five errors of a batch that raised more, and **Copy Details** copies all of them.

### Stop an import

![Stop Import dialog offering rollback, commit, and Continue for genre rows](https://mintcdn.com/ngquct/N25lTvAgKWN7Aqr5/images/import-stop.png?fit=max\&auto=format\&n=N25lTvAgKWN7Aqr5\&q=85\&s=e84b9641108b2014eb322da29efe8853)

Choose what to do with the paused import

Click **Stop** during a SQL or row import. **Pausing…** means a database operation already in progress is finishing. The **Stop Import?** question appears after that operation finishes; no further import work starts while you decide. A PostgreSQL `COPY` block is the exception: **Stop** ends it at once and stops the import with no question.

Choose **Continue** to resume. When the import still controls a healthy open transaction and can identify its changes, the question offers **Stop and Rollback** and **Stop and Commit**. It names transactional tables separately from tables whose changes stay either way. In other cases, **Stop Import** ends the run with the limits described in the question. A message that changes may stay is not a promise of rollback.

After stopping, read the result for each file: not imported, direct changes rolled back, changes committed or kept, changes still in an open transaction, or changes that may stay. Row counts describe rows submitted in completed writes, not an exact count of rows inserted. A failed write can have made additional changes. **Copy Details** includes the recorded errors and transaction or session cleanup failures.

If a transaction was already open before the import, commit or roll it back yourself. The same applies when the file opens or replaces a transaction. A failed open transaction needs rollback. The result lists table creation and table clearing done before row import separately; rolling back the rows does not undo preparation already committed.

### Disabling foreign key checks

The checkbox runs a different statement per engine, and one of them needs a privilege.

| Engine | Statement | Needs |
| - | - | - |
| PostgreSQL, Redshift, CockroachDB, PGlite | `SET session_replication_role = replica` | Superuser, or `GRANT SET` on the parameter from PostgreSQL 15 |
| MySQL, MariaDB | `SET FOREIGN_KEY_CHECKS=0` | Nothing |
| SQLite, libSQL, Cloudflare D1 | `PRAGMA foreign_keys = OFF` | Nothing |
| Everything else | Nothing. The option is ignored | |

A server that rejects the statement stops the import with that error, so clear the checkbox and run it again. A dump TablePro exported usually needs no privilege, because its tables are already ordered parents first. On PostgreSQL and Oracle, whose `CREATE TABLE` leaves foreign keys out, the dump adds them with `ALTER TABLE … ADD CONSTRAINT` after the data instead.

### Import JSON

The sheet accepts an array of objects `[{…}, {…}]`, newline-delimited JSON streamed a line at a time, a single object as one row, and TablePro's own export shape `{ "table": [ {…} ] }`, so an export round-trips. A `.json` file is read one value at a time whatever its size, in UTF-8, UTF-16 or UTF-32, with or without a byte order mark. Then choose a destination:

* **Existing table**: map each JSON field to a column, as [Map fields to columns](#map-fields-to-columns) describes. A column with no field mapped to it keeps its default or NULL. The list holds tables and partitioned tables, and the server routes each row to the right partition.
* **New table**: the name field opens on a name derived from the file, already selected, so one keystroke replaces it. Review the inferred columns underneath. Name, type, primary key, nullable flag, and default are all editable before the table is created.

Both lists come from every row in the file. A key that only the last rows carry is still offered, and an inferred type fits every value the field holds, so a field that is a number in all rows but one is typed as text.

The proposed name drops the extension, turns spaces and punctuation into underscores, and lowercases the result. Letters from any script are kept as they are. On Oracle the name comes through in upper case instead, and is cut to 30 bytes rather than 63. A name an existing table or view already holds gains a numeric suffix, so re-importing `users.csv` next to a `users` table proposes `users_2`. Whatever you type over it is held to the same rules: a name already taken, one longer than the engine allows, or one starting with a prefix the engine keeps for itself is reported in the sheet, with **Import** off until it changes.

The table list, the new table and the rows all belong to the database and schema the connection was on when the sheet opened. Switching database in another window while the sheet is open leaves the import where it was.

Rows insert through parameterized statements, so a JSON value is never concatenated into SQL. Nested objects and arrays are stored as JSON text. In a new PostgreSQL table their column is `jsonb`, or `json` on 9.2 and 9.3, and `text` on 9.1, which has no JSON type.

### Import XLSX

Reads the first worksheet of an `.xlsx` workbook. The destinations and the proposed new-table name
behave as they do for JSON.

| Option | Default |
| - | - |
| First row holds column names | Yes |
| Trim whitespace | No |
| Treat empty cells as NULL | Yes |

A row that omits its empty cells still lands in the right columns: each cell's own reference decides where it goes, not its position among the cells that were written. Text stored in the workbook's shared string table is resolved, including a value split across several formatting runs.

The workbook is read whole rather than streamed, because a sheet's rows refer back to a string table that has to be held anyway.

### Import CSV

CSV and TSV open the same sheet as JSON, with parsing options in front of the mapping. The delimiter and encoding are detected from the file. Changing any option reads the file again. A field that is still there keeps the column it was mapped to. In a new table each column setting you changed stays with its field, even through a read that misses the field, such as one with the wrong delimiter. Settings you left alone follow the new read, such as a type inferred again from trimmed values.

| Option | What it does | Default |
| - | - | - |
| Delimiter | Comma, semicolon, tab, or pipe | Auto-detect |
| Quote character | Double or single quote | Double quote (`"`) |
| Encoding | UTF-8, UTF-16 LE, UTF-16 BE, ISO Latin 1, Windows-1252, Shift JIS, EUC-JP, GB 18030, Big5, or EUC-KR | Auto-detect |
| First row is a header | Row 1 becomes the column names; off imports it as data | Yes |
| Trim leading and trailing spaces | Trims each field before import | No |
| Treat empty values as NULL | Inserts NULL instead of empty text | Yes |
| NULL text | One more value to import as NULL, `\N` for instance | None |

Quoted fields keep embedded commas and newlines (RFC 4180), and a doubled quote (`""`) decodes to one. A line the encoding cannot read stops the import before any row is deleted or inserted, and the error names the line.

### Map fields to columns

Every field in the file gets a row with a checkbox and a column menu. A field named like a column, ignoring case, starts mapped to it. The rest start on **Skip**.

**Match Columns** above the rows fills them all at once:

| Item | Result |
| - | - |
| **Match by Name** | Each field goes to the column of the same name, ignoring case. Fields with no such column are skipped |
| **Match by Position** | The first field goes to the first column, the second to the second, and so on. Dimmed for JSON, whose fields are listed alphabetically |
| **Use Saved Mapping** | Puts back the mapping saved for this table |

Clicking **Import** saves each choice that differs from Match by Name for that table, whether the import succeeds or not. The next file imported into the same table starts from those choices, and the sheet reads **Restored the mapping saved for** and the table name. A saved column the table no longer has falls back to the name match. Importing into a new table saves any column you renamed, so the same file lands on the renamed columns next time.

Saved mappings stay on this Mac. They follow a renamed table and are forgotten when the table is dropped, from the sidebar or with SQL as [Drop or rename with SQL](https://docs.tablepro.app/features/table-operations.md#drop-or-rename-with-sql) describes, and when the connection is deleted.

### Row imports

CSV and JSON insert in batches, and the on-error and transaction options behave as they do for SQL. They add **Delete existing rows before import**, which clears the target table before writing rows. The deletion rolls back only if it belongs to a transaction the import rolls back and the table supports rollback. A row where no field matches a mapped column writes nothing and is reported rather than counted.

A binary column reads a value the way the export wrote it: `0x` and hex digits from CSV and XLSX, `0x` alone for zero bytes, and Base64 from JSON. A CSV or XLSX value without `0x`, or a JSON value that is not Base64, is written as its text. A value that starts with `0x` but is not hex fails its row. On MySQL, MariaDB, SQL Server and SQLite, a boolean column takes `true`, `false`, `yes`, `no`, `on`, `off`, `t`, `f`, `y` and `n` as `1` and `0`.

A CSV line of empty fields, such as `,,`, is a row, the way CSV export writes a row of NULLs. An empty line is skipped, except in a file of one column, where it is that column's NULL. Empty lines and lines of empty fields after the last value are not rows: a spreadsheet saves its empty rows that way. A JSON row `{}` is a row of column defaults.

### Update existing rows

**Import as** decides what an import into an existing table does with a row whose key the table already holds:

| Import as | Key already in the table | Key not in the table |
| - | - | - |
| **Insert** | Inserted, so a duplicate key fails | Inserted |
| **Update** | Mapped columns updated | Skipped |
| **Insert or Update** | Mapped columns updated | Inserted |
| **Insert, Skip Existing** | Skipped | Inserted |

![Row import sheet with Import as set to Update and Match on set to the primary key](https://mintcdn.com/ngquct/mTqrQeYnrO38oiNe/images/row-import-update.png?fit=max\&auto=format\&n=mTqrQeYnrO38oiNe\&q=85\&s=4dd11a5b61a34da6c9268989d0c9ef8f)

Import as Update, matched on the primary key

**Match on** picks the key: the primary key, or a unique index over plain columns. Map a field to every column of the key, and for **Update** or **Insert or Update** to at least one column outside it. A table with neither a primary key nor a unique index takes **Insert** only.

An update writes the mapped columns outside the key and leaves every other column as it was, so a file can correct one column of a table without carrying the rest. Each batch is looked up by key on the server first, so the database's own comparison decides what matches. A key the file repeats updates the row its first occurrence wrote. A key holding NULL matches no row. A key that matches more than one row is not written: Skip and Continue records it against its line, and the stop modes stop there.

**Delete existing rows before import** works with **Insert** only. With any other choice the import stops before it writes a row.

On ClickHouse an update is an `ALTER TABLE … UPDATE` mutation, and the import waits for each one to apply before it reads the next batch. A column of the sorting, primary or partition key keeps its value on a matched row, since ClickHouse cannot change it, and is written only for an inserted row. See [ClickHouse](https://docs.tablepro.app/databases/clickhouse.md#updating-rows-outside-the-grid).

The summary counts the rows matched, updated, inserted and skipped, and under Skip and Continue the ones that failed.

### Import several files

Select several files in **Import Data…**, or a folder, and each one loads into its own table in one run. A folder brings the `.csv`, `.tsv`, `.json`, `.jsonl`, `.ndjson`, and `.xlsx` files directly inside it. Files in its subfolders stay out, and a file that does not load into a table, a `.sql` dump among them, is named in the sheet and left out. A folder holding a single such file opens the one-file sheet. Drop more files or folders on the list to add them.

![Sheet listing files with a destination menu and column count per file](https://mintcdn.com/ngquct/16FpSC9zC9Nm4Ce-/images/import-several-files.png?fit=max\&auto=format\&n=16FpSC9zC9Nm4Ce-\&q=85\&s=d9aaa9b00c3cbb2235e1033783b50bdf)

Three files of a folder, each on its own table

Each file starts on the table its name matches, ignoring case, or on a new table under the name a single import would propose. No two files get the same new name: `sales.csv` and `sales.json` propose `sales` and `sales_2`. In a file's row, pick another destination from the menu, clear the checkbox to leave the file out, or click **Edit…** for the one-file sheet: the column mapping of an existing table, starting from its saved mapping, or the columns of a new table. A run only inserts, so that sheet has no **Import as**: [update existing rows](#update-existing-rows) one file at a time.

The options under the list apply to every file of that format. With **Auto-detect** set, the delimiter and encoding are still read from each file. A run that mixes formats shows the options of each, and their **On error** and **Wrap in transaction** have to match, because the run shares one transaction when transaction wrapping is available.

| On error | What a failure in one file does |
| - | - |
| **Stop and Rollback** | Stops there and rolls back the shared transaction if it is still under import control. Direct changes to transactional tables roll back together; nontransactional changes stay |
| **Stop and Commit** | Stops there and commits completed writes in the shared import transaction, unless that transaction has failed |
| **Skip and Continue** | Skips the failing row, or the whole file when it cannot be read, and carries on. No import transaction |

New tables are created before any rows go in. Retrying from the same sheet can reuse and clear those tables before row import starts. Review the preparation details in a stopped or failed result; a later rollback does not undo a clearing operation already committed. [Safe Mode](https://docs.tablepro.app/features/safe-mode.md) asks once for the whole run. The summary lists each file with its table and row count, and **Copy Details** adds every skipped row's error. [Stopping the run](#stop-an-import) reports each file's outcome separately, including files already processed and files not reached.

Two files can fill one existing table, except with **Delete existing rows before import** on: the second file would clear the first one's rows.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.