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:
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:
UNLOAD 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.
|Send feedback about this page via email or DocCommentXchange||Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0|