To export data from a database table into an external ASCII-format file.
Syntax
UNLOAD [ FROM ] TABLE [ owner. ]table-name
... TO 'filename -string '
... [ FORMAT ASCII ]
... [ DELIMITED BY string ]
... [ QUOTES ON | OFF ] [ ESCAPES ON | OFF ]
... [ ORDER ON | OFF ]
... [ ESCAPE CHARACTER character ]
Description
The UNLOAD TABLE statement allows efficient mass exporting from a database table into an ASCII file. UNLOAD TABLE is more efficient than the Interactive SQL statement OUTPUT, and can be called from any client application.
UNLOAD TABLE places an exclusive lock on the whole table.
When unloading columns with binary data types, UNLOAD TABLE writes hexadecimal strings, of the form \xnnnn where n is a hexadecimal digit.
For descriptions of the FORMAT, DELIMITED BY, and ESCAPE CHARACTER options, see LOAD TABLE statement . The other options are as follows:
QUOTES option With QUOTES turned on (the default), single quotes are placed around all exported strings.
ESCAPES option With ESCAPES on (the default), backslash-character combinations are used to identify special characters where necessary on export.
ORDER option With ORDER on (the default), the data is exported ordered by primary key values. With ORDER off, the data is exported in the same order you see when selecting from the table without an ORDER BY clause.
Exporting is slower with ORDER on. However, reloading using the LOAD TABLE statement is quicker because of the simplicity of the indexing step.