Contents Index UNION operation UNLOAD TABLE statement

ASA SQL Reference
  SQL Statements

UNLOAD statement


Description 

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

Syntax 

UNLOAD select-statement TO filename-string [ unload-option ... ]

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

Parameters 

filename-string    The filename to which the data is to be unloaded. Because it is the database server that executes the statements, filenames specify files on the database server machine. Relative filenames specify files relative to the database server's starting directory. To unload data onto a client machine, see OUTPUT statement [Interactive SQL].

Usage 

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 \xnnnn 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.

For more information, see -gl server option.

Side effects 

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

See also 

UNLOAD TABLE statement

OUTPUT statement [Interactive SQL]

Standards and compatibility 

Contents Index UNION operation UNLOAD TABLE statement