Export Oracle SQL Developer results to CSV

A practical review of the ways to get Oracle SQL Developer query output into CSV, what the conversion changes, and where CSV breaks down for sharing or spreadsheets.

Is CSV the right format for your SQL Developer output?

For most people who want to move query results out of Oracle SQL Developer and into a spreadsheet, a script or another database, CSV is a sensible default. Its main benefit is reach. It is plain text that almost any tool can read, and it keeps rows and columns intact without needing a database connection. The decisive tradeoff is that CSV holds characters but not data types. Dates, numbers with leading zeros, long text and NULLs all become text that the receiving program has to interpret, and spreadsheet programs often interpret them in ways you did not intend.

CSV is a poor choice in some cases. If people will read the results rather than process them, a formatted report or a fixed-width text listing is usually easier on the eye. If the data must round-trip exactly into another Oracle database, a format that carries type information, such as SQL insert statements or a native export, is usually safer. If the data contains many embedded line breaks or large text columns, a delimiter-based file can be technically valid but awkward to inspect.

What the conversion changes

This is a delimited-text transformation. It does not reverse, mirror or substitute characters, and the word "format" here refers to the output layout, not to fonts or styled Unicode. SQL Developer takes each row of a result set and writes its column values as text. A delimiter, usually a comma, separates the values, and a line break ends each row. Text values are normally wrapped in an enclosure character, usually a double quote, so that commas or line breaks inside a value do not split it into extra columns. A header row with column names is typically included.

The stored data in the database is not altered. What changes is the representation:

  • Numbers, dates and timestamps are converted to text strings. Date and timestamp text generally follows the session's NLS formatting settings unless you format the values yourself in the query, for example with TO_CHAR.
  • NULL values usually become empty fields, which a reader cannot distinguish from an empty string without extra context.
  • Character data is written in a chosen file encoding. If the receiving program assumes a different encoding, accented letters and non-Latin scripts can appear garbled even though the file itself is correct.
  • Right-to-left text, such as Arabic or Hebrew, is stored in logical order in the file just as in the database. How it looks on screen depends on the viewer's bidirectional text handling, not on the export.
  • Large object columns such as CLOBs and BLOBs may be truncated, omitted or handled differently from ordinary columns, depending on the version and settings. Check your output if those columns matter.

Ways to produce CSV in SQL Developer

There are three common routes. Menu names and defaults can differ between SQL Developer versions, so treat the descriptions below as orientation and confirm them against the version you have installed.

Method | How it works | Best suited for | Main caveat
Export wizard from the results grid | Right-click the query result grid, choose Export, select CSV as the format, then set the delimiter, enclosures, encoding and destination file | One-off exports where you want to adjust options interactively | The wizard may re-run the query to collect all rows rather than only the rows shown in the grid. Expect that, especially for slow or changing queries.
CSV comment hint in a script | Add the /csv/ hint after SELECT and run the statement as a script rather than as a single statement | Quick output into the Script Output panel for copying | The output appears as text in a panel. You still have to save or copy it, and the panel may not be practical for very large results.
SET SQLFORMAT CSV with SPOOL | Set the script output format to CSV, spool to a file, run the query as a script, then stop spooling | Repeatable or scripted exports that should write directly to a file | Spooled files can include extra lines such as the echoed command or row-count feedback unless you turn those off.

An example of the hint approach. Run it with the Run Script command, commonly bound to F5, rather than Run Statement:

SELECT /*csv*/ employee_id, last_name, hire_date
FROM employees;

An example of a scripted export to a file. The file name is a placeholder. The feedback setting suppresses the trailing row-count message, which you may otherwise see in the file:

SET SQLFORMAT CSV
SET FEEDBACK OFF
SPOOL employees.csv
SELECT employee_id, last_name, hire_date FROM employees;
SPOOL OFF
SET FEEDBACK ON
SET SQLFORMAT

The general shape of the resulting text is shown below. This is an illustration of the layout described above, not captured output. Quoting rules, header case and date formatting depend on your version and session settings:

"EMPLOYEE_ID","LAST_NAME","HIRE_DATE"
100,"King",17-JUN-03
101,"Kochhar",21-SEP-05

The illustration fits the mechanism. Each row is one line, values are separated by commas, and text is enclosed in quotes. The date appears in a default-style text format rather than as a typed value. If you need a predictable date layout, format the column explicitly in the query instead of relying on session defaults.

Will the file stay readable and usable after you share it?

Because CSV is plain text, it copies and pastes without hidden styling. It can be opened in a text editor, version-controlled and searched with ordinary tools. Most usability problems come from the program that opens the file, not from the file itself.

  • Spreadsheet interpretation: Spreadsheet programs commonly convert values as they open a CSV. They may strip leading zeros from codes such as postal or account numbers, turn long numeric identifiers into scientific notation, or reinterpret dates. Importing through the spreadsheet's text-import feature, and marking those columns as text, avoids this more reliably than double-clicking the file.
  • Encoding: If non-ASCII characters look wrong after opening, the file and the reader probably disagree about encoding. Exporting as UTF-8 is a reasonable default. Some spreadsheet programs only detect UTF-8 reliably when the file starts with a byte order mark, so check how your destination behaves.
  • Regional delimiters: In locales where the comma is the decimal separator, spreadsheets may expect semicolons between fields. If columns all land in one cell, change the delimiter in the export options or in the import step.
  • Embedded line breaks and quotes: Values containing line breaks or double quotes are valid CSV when enclosed and escaped correctly, but simple line-by-line tools and some importers mishandle them. If a downstream tool is fragile, clean or replace those characters in the query.
  • Accessibility: A CSV file has no visual formatting, so it does not introduce the problems that styled or substituted characters cause for screen readers. Whether a table is navigable with assistive technology depends on the program used to open it. No documentation or tests were provided for specific screen readers or applications, so confirm with the tools your audience actually uses.
  • Editing and search: Search and editing work on the actual characters, so there is no hidden transformation to undo. The main risk is that someone opens the file in a spreadsheet, saves it, and silently loses leading zeros or changes date formats. Keep the original export if exact values matter.

Sometimes a different plain-text equivalent is a better fit than CSV. If the output is meant to be read by people in an email, chat message or ticket, a fixed-width listing or a short formatted table is easier to scan. If it is meant to be loaded back into Oracle, generated insert statements or a dedicated export format preserve types better than CSV.

Gaps in this review

No version-specific documentation, measurements or test results were supplied for this article. The descriptions of menus, hints and script settings reflect commonly documented SQL Developer behavior, but defaults can change between releases. Behavior with large object columns, very large result sets and particular spreadsheet or assistive-technology destinations has not been verified here. Run a small test export with your own data, open it in the actual destination, and check dates, leading zeros, special characters and NULLs before relying on the process.