Help Import, export and backup

Exporting data

Export As saves rows to a file for use in other programs: a spreadsheet, a web page, another application. To back up a database so it can be rebuilt, use an SQL dump instead.

The Export As dialog

Opening it

FromWhat is exported
Table > Backup/Export > Export Table Data As… (Ctrl+Alt+C)Every row of the table selected in the Object Browser.
The Export as… button (the first one on the toolbar) of the Table Data or Result tab, or Tools > Export All Rows Of Table Data/Result As… (Ctrl+Shift+E)The rows the tab holds, so Limit rows and any filter apply. A new row that is not saved yet is left out.

Choosing the format

FormatGives
CSVText with one row per line, with the separators set under CSV Options.
JSONThe rows as JSON. Numbers are written without quotes.
HTMLA web page with the rows in a table.
XMLThe rows as XML elements.
Excel XMLA spreadsheet in Excel’s XML format, with the settings under Excel Options.
SQLINSERT statements, and optionally the CREATE TABLE, with the settings under SQL Options.

When you change the format, bonSQL changes the extension of the file name to match.

BIT columns are written as numbers in CSV, JSON, HTML, XML and Excel XML, for example 5 for b'101'.

CSV Options

The box shows the current separators: fields Terminated by, Enclosed by and Escaped by, lines Terminated by, and what NULL is replaced by. Unless you change them, they are \t (a tab), <NONE>, \\, \n and \N.

Add column names on top writes a first line of column names.

Click Change… to set them in the Specify The Escape Characters window. Each setting has a tick box in front of it; untick it to leave that part out. Click OK when done.

FieldDoes
Escaped byThe character put before special characters inside values.
Lines terminated byWhat ends each row, for example \r\n for Windows.
Fixed length / Variable lengthFixed length pads every value to the column’s width instead of using separators. It does not support BLOB and TEXT columns; bonSQL warns and asks whether to go on.
Fields terminated byThe separator between values, for example , or \t for tab.
Fields enclosed byThe character put around values, usually ". With Optionally, only CHAR, VARCHAR, ENUM and SET values are enclosed.
NULL value replaced byWhat to write for NULL.
Fill Excel Friendly ValuesSets comma-separated values enclosed in ", escaped by \\, lines ending \r\n and NULL as \N.

Excel Options

Text column size limit and Decimal places control how long text and decimal numbers are written to the sheet.

SQL Options

Structure only, Data only or Structure and data, and Include bonSQL version for a comment naming bonSQL at the top. bonSQL reminds you that this writes the simplest form of SQL, without indexes, character sets or comments. From the Result tab, SQL is only offered when the query reads from one table.

Columns, character set and file

Click Export. The dialog counts the rows as they are written, and the button reads Stop until it finishes. At the end, bonSQL offers to open the file (for SQL it only says that the export succeeded).

Copying instead of saving

To paste rows straight into another program, use the Copy Data button on the Table Data or Result tab, or right-click and choose Copy for one cell, all rows, or the selected rows.

When it does not work

MessageUsually means
Please specify a file nameSave to file is empty.
Please select at least one columnNo column is selected in Select Field(s) To Export.
Could not create fileThe folder does not exist, the file is open in another program, or you may not write there.
Fixed-length CSV is not supported for BLOB and TEXT columns. Do you still want to continue?Answer No, then choose Variable length under Change…, or leave those columns out.