Using the UNLOAD TABLE statement

The UNLOAD TABLE statement lets you export data efficiently in text formats only. The UNLOAD TABLE statement exports one row per line, with values separated by a comma delimiter. The data is exported in order by primary key values to make reloading faster.

Use the UNLOAD TABLE statement when you:

  • want to export entire tables in text format
  • are concerned about database performance
  • export data to a file on a client computer
Impact on the database

The UNLOAD TABLE statement places an exclusive lock on the whole table while you are unloading it.

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

Example

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

UNLOAD TABLE Employees TO 'employee_data.csv';

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

See also