Moving Oracle Table Data to CSV Without Hand-Written Spool Scripts
Oracle SQL Developer's Export Wizard replaces hand-written spool scripts for moving table data to CSV. Here is how to use it, verify the output, and automate it with sdcli.
30 Sept 2026, 12:08 UTC

If you have ever needed to get a table out of Oracle and into a data warehouse, a reporting spreadsheet, or an analyst's inbox, you know the routine: write a SQL*Plus spool script, fight with column separators, fix the quoting on VARCHAR2 values, and hope nobody asks for it again next week. It works, but it is fragile and tedious.
Oracle SQL Developer ships with an Export Wizard that does this job in a guided, repeatable way. It handles CSV, Excel, JSON, and XML output, preserves sensible type formatting, optionally filters rows, and shows you the generated script before anything runs. This post walks through how it works, a concrete export of the HR sample schema, and the limits you should know before relying on it for big extracts.
What the Export Wizard actually does
In SQL Developer's Connections navigator, right-click any table or view and choose Export…. The wizard then walks you through the decisions that matter:
- Object selection – the table or view you clicked, with the option to include DDL alongside the data.
- Output format – CSV, Excel (xlsx), JSON, XML, loader, insert statements, and others depending on your SQL Developer version.
- File location – where the output lands on your local machine.
- Row filtering – an optional WHERE clause, so you can export a slice instead of the whole table.
- Formatting options – include column headers, control LOB handling, and tweak delimiters or quoting for CSV.
The last page of the wizard shows a preview of the script it is about to run. That preview is worth reading the first few times: it tells you exactly what SQL Developer will execute, which makes the operation auditable rather than a black box.
Worked example: exporting HR.EMPLOYEES to CSV
Assume you are connected to the HR sample schema in SQL Developer (this applies to recent SQL Developer releases; menu labels have been stable for years, but check your version if something looks different).
- Expand your HR connection, right-click the
EMPLOYEEStable, and choose Export…. - Set Format to
CSV. - Set File to
/tmp/employees.csv(or a Windows path likeC:\exports\employees.csv). - Check Include column headers and leave Export data enabled.
- Optionally add a filter, for example
WHERE department_id = 10, if you only need one department. - Click Next, review the generated script on the summary page, then Finish.
The result is a file whose first line is the column names, followed by one row per record. NUMBER columns come out as unquoted numerics, VARCHAR2 values are quoted as needed, and dates are rendered in the session's display format. That last point matters: if downstream tooling expects ISO dates, set your NLS date format in SQL Developer's preferences before exporting rather than fixing the file afterward.
Verifying the export actually worked
Do not trust the wizard's success dialog as your only check. Two quick verifications catch most problems:
- Row count comparison. Run
SELECT COUNT(*) FROM employees;in a worksheet, then in a shell runwc -l /tmp/employees.csv. The line count should equal the table count plus one for the header (assuming no embedded newlines in your data, which is itself worth checking). - Spot-check the content. Open the CSV in a text editor, not just Excel. Confirm the header matches the column names, numeric values are unquoted, and no rows appear truncated mid-line.
Trade-offs and limitations
The wizard is a good fit for moderate extracts — up to a few hundred thousand rows is generally comfortable. Beyond that, two issues bite:
Memory and runtime. SQL Developer is a GUI client, and very large exports can be slow or memory-hungry. For recurring or large jobs, use the command-line interface instead. SQL Developer ships sdcli (or sdcli64 on some installs), which exposes export operations without the GUI. A typical invocation looks like:
sdcli -dbconn myconn -export -format csv \
-object employees -file /tmp/employees_cli.csvRun this from the machine where SQL Developer is installed, with a saved connection named myconn. The exact flags vary by SQL Developer version, so run sdcli -help (or check the export subcommand help) on your install before scripting it. A practical cross-check: run the same export through the wizard and through sdcli, then diff the two files — they should match apart from possible whitespace differences.
LOB truncation. CLOB and BLOB values larger than about 4 KB may be truncated unless you enable the LOB export option, which inflates file size considerably. If your table has large LOBs, verify a known long value end-to-end before assuming the export is complete.
Driver and format caveats. A JDBC driver that does not match your database version can produce unexpected string formats for types like TIMESTAMP WITH TIME ZONE. And exporting to real Excel (.xlsx) requires optional Apache POI libraries; if they are missing, SQL Developer silently falls back toward CSV behavior, so confirm the Excel option is actually enabled in the dialog before promising someone a spreadsheet.
Closing thought
The Export Wizard turns a hand-rolled spool script into a two-minute, reviewable operation — and the script preview plus sdcli give you a path from ad-hoc export to scheduled automation. Next time you need table data out of Oracle, run the wizard once, verify the row count against the source, and save the generated script as the starting point for your repeatable version.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.