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 Reference » SQL Statements

UNION statement Next Page

UNLOAD statement


Use this statement to export data from a database into an external ASCII-format file.

Syntax

UNLOAD select-statement
TO file-name
[ unload-option ... ]

unload-option :
APPEND {ON|OFF}
| DELIMITED BY string
| ESCAPE CHARACTER character
| ESCAPES {ON | OFF}
| FORMAT {ASCII | BCP}
| HEXADECIMAL {ON | OFF}
| QUOTE string
| QUOTES {ON | OFF}

file-name : string | variable

Parameters

file-name    The file name to which the data is to be unloaded. Because it is the database server that executes the statements, file-name specifies a file on the database server computer. A relative file-name specifies a file relative to the database server's starting directory. To unload data onto a client computer, see PASSTHROUGH statement [SQL Remote].

Remarks

The UNLOAD statement allows the result set of a query to be exported to a comma-delimited file. The result set is not ordered unless the query itself contains an ORDER BY clause.

When unloading result set columns with binary data types, UNLOAD writes hexadecimal strings, of the form \0xnnnn where n is a hexadecimal digit.

For a description of the unload-option parameters, see UNLOAD TABLE statement.

When unloading and reloading a database that has proxy tables, you must create an external login to map the local user to the remote user, even if the user has the same password on both the local and remote databases. If you do not have an external login, the reload may fail because you cannot connect to the remote server.

For more information about external logins, see Working with external logins.

When the APPEND option is ON, unloaded data is appended to the end of the file specified. When the APPEND option is OFF, unloaded data replaces the contents of the file specified. This option is OFF by default.

Permissions

The permissions required to execute an UNLOAD statement are set on the database server command line, using the -gl option. See -gl server option.

Side effects

None. The query is executed at the current isolation level.

See also
Standards and compatibility