Export Query Results to CSV in DBeaver
Export a DBeaver query result to CSV with headers, UTF-8 encoding, and empty nulls, then validate row count and quoting before downstream use.
02 Jul 2026, 23:10 UTC

Desired outcome
You need a query result or table from DBeaver as a CSV file: column headers in the first row, UTF-8 encoding, comma delimiter, and empty strings for null values. The file should be ready for loading into another system or inspecting in a text editor without manual cleanup.
Use the Data Editor's Export Data dialog rather than copying from the grid. Copying can drop rows, mangle line breaks, and omit headers depending on the grid's fetch size.
Prerequisites
- DBeaver Community or Enterprise installed and running. Menu labels and export options vary by edition and release; open
Help > Aboutto confirm your version before following these steps. - A saved database connection with a working JDBC driver, the software component that lets DBeaver communicate with the database.
- Database user privileges to
SELECTfrom the target table or view. - Write permission to the destination folder and enough free disk space for the export.
Export a query result to CSV
- In Database Navigator, expand the connection and schema, then right-click the target table and choose View Data. Alternatively, run a
SELECTstatement in the SQL Editor and open the results tab. - In the Data Editor toolbar, click Export Data.
- Set Format to
CSV. - Set Delimiter to a comma:
,. - Set Encoding to
UTF-8. - Enable Include headers.
- Set Null string to an empty value so nulls export as empty fields rather than the word
NULL. - Choose the output file path, for example
/exports/orders_2026.csv. - Start the export and leave DBeaver open until the progress dialog finishes.
Example export configuration
Format: CSV
Delimiter: ,
Encoding: UTF-8
Include headers: enabled
Null string: (empty)
File path: /exports/orders_2026.csv
If you are exporting a query instead of a whole table, run the query first with a LIMIT clause to validate behavior on a small subset before exporting millions of rows.
Validate the exported file
- Run
SELECT COUNT(*)for the same query in DBeaver and note the result. - Count lines in the CSV. Run this in a terminal on the machine where the file was saved:
- Open the file in a text editor and inspect:
- First line matches the expected column names.
- First and last data rows contain expected values.
- Fields with commas, quotes, or newlines are wrapped in double quotes.
- Dates, timestamps, and decimals appear in readable text form.
- Null values appear as empty fields, not the literal text
NULL. - Optionally re-import the CSV into a temporary DBeaver table or spreadsheet and compare column count and sample values against the source result set.
wc -l /path/to/export.csv
Required permissions: read access to the file. Placeholder: replace /path/to/export.csv with your actual path. Expected result: line count equals the source row count plus one header line. Risk: if a CSV field contains a quoted newline, wc -l counts it as multiple lines, so a mismatch does not always mean rows were lost.
If the export fails or looks wrong
- Cancel the export, then check disk space, destination folder permissions, and database connection stability.
- Delete any partially written file before retrying so a truncated file is not mistaken for a complete export.
- Retry with a smaller
LIMITsubset, a different encoding, or a semicolon delimiter if the target system expects semicolon-separated values. - Use XLSX or JSON format if CSV quoting causes problems for the downstream loader.
- Compare source
COUNT(*)to exported rows and re-run from the last successful checkpoint if you are exporting in batches.
Limitations and version notes
- CSV does not preserve database types. Validate dates, timestamps, decimals, and nulls after importing into the target system.
- An exported CSV is not a database backup. It contains no schema, constraints, indexes, or transactional consistency.
- Very large exports can consume significant memory and disk space. Filter with
WHEREorLIMITbefore a full export. - Export dialog labels and available formats differ across DBeaver Community, Enterprise, and releases. If Export Data is missing from the Data Editor toolbar, confirm your edition and version in
Help > About.
There is no database rollback for this operation because exporting reads data without modifying the database. The only recovery step is to remove a partial output file and retry.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.