Icon EXPORT TABLE Statement

Introduction
The SQL EXPORT TABLE statement is used to export a table to a delimited text file.

Syntax
EXPORT TABLE [IF EXISTS] table_reference [EXCLUSIVE]

TO text_file_name

[DELIMITER delimiter_character]

[WITH HEADERS]

[COLUMNS (column_name [, column_name])]

[DATE date_format]
[TIME time_format]
[DECIMAL decimal_separator]

Use the EXPORT TABLE statement to export a table to a delimited text file specified by the TO clause. The file name must be enclosed in double quotes ("") or square brackets ([]) if it contains a drive, path, or file extension. Use the EXCLUSIVE keyword to specify that the table should be opened exclusively.


DELIMITER Clause
The DELIMITER clause is optional and specifies the delimiter character to use in the exported text file. The DELIMITER character should be specified as a single character constant enclosed in single quotes ('') or specified using the pound (#) sign and the ASCII character value. The default delimiter character is the comma (,).

WITH HEADERS Clause
The WITH HEADERS clause is optional and specifies that the exported text file should contain column headers for all columns as the first row.

COLUMNS Clause
The columns clause is optional and specifies a comma-separated list of columns that should be exported to the text file. The column names specified here must conform to the column naming conventions for DBISAM's SQL and must exist in the table being exported. Please see the Naming Conventions topic for more information.

DATE, TIME, and DECIMAL Clauses
The DATE, TIME, and DECIMAL clauses are optional and specify the formats and decimal separator that should be used when exporting dates, times, timestamps, and numbers. The DATE and TIME formats should be specified as string constants enclosed in single quotes ('') and the DECIMAL separator should be specified as a single character constant enclosed in single quotes ('') or specified using the pound (#) sign and the ASCII character value. The default date format is 'yyyy-mm-dd', the default time format is 'hh:mm:ss.zzz ampm', and the default decimal separator is '.'.

The statement below exports three fields from the Employee table into a file called 'employee.txt':

EXPORT TABLE Employee
TO "c:\mydata\employee.txt"
WITH HEADERS
COLUMNS (ID, FirstName, LastName)

Please see the Importing and Exporting Tables and Query Result Sets topic for more information on exporting tables.
Image