Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.0 » SQL Anywhere Server - SQL Usage » Remote Data and Bulk Operations » Importing and exporting data » Exporting data » Export tools


Using the UNLOAD statement

The UNLOAD statement is similar to the OUTPUT statement in that they both export query results to a file. The UNLOAD statement, however, allows you to export data in a more efficient manner and in text formats only. The UNLOAD statement exports with one row per line, with values separated by a comma delimiter.

Use the UNLOAD statement to unload data when you want to:

  • export query results if performance is an issue
  • store output in text format
  • embed an export command in an application
  • export data to a file on a client computer
Impact on the database

If you have a choice between using the OUTPUT statement, UNLOAD statement, or UNLOAD TABLE statement, choose the UNLOAD TABLE statement for performance reasons.

To use the UNLOAD statement, the user must the permissions required to execute the SELECT that is specified as part of the statement.

For more information about controlling who can use the UNLOAD statement, see -gl server option.

The UNLOAD statement is executed at the current isolation level.


Using the SQL Anywhere sample database, you can unload a subset of the Employees table to a text file named employee_data.csv by executing the following command:

SELECT * FROM Employees 
WHERE State = 'GA'
TO 'employee_data.csv';

Because it is the database server that unloads the result set, employee_data.csv specifies a file on the database server computer.

See also