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

SQL Anywhere 10.0.1 » SQL Anywhere Server - SQL Usage » Importing and Exporting Data » Exporting data from databases » Export tools

Using the UNLOAD TABLE statement Next Page

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/ASCII 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:

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.

For more information, see UNLOAD statement.


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.