Exporting data from a database, Using output redirection – Sybase 12.4.2 User Manual

Page 194

Advertising
background image

Exporting data from a database

174

Exporting data from a database

This section tells how to export data from an Adaptive Server IQ database.

Note

To export IQ data from your database in this version of Adaptive Server

IQ, Sybase recommends that you use the method described in this chapter. You
may also export data by using a front end tool, written by you or a third party,
that effectively queries the IQ database and formats the data as desired.

If you need to export tables (other than your system tables) from your Catalog
Store, use the method in this chapter, or see the Adaptive Server Anywhere
Reference Guide
for other ways to unload data.

Using output redirection

Output redirection can be used to export query results.

You can redirect the output of any command to a file or device by putting the

>#

redirection symbol anywhere on the command. The redirection symbol

must be followed by a file name. (In a command file, the file name is then
followed by the semicolon used as statement terminator.) The file is placed
relative to the directory where DBISQL was started.

In this example, output is redirected to the file empfile:

SELECT *

FROM employee

># empfile

Do not enclose the file name in quotation marks.

Output redirection is most useful on the

SELECT

statement. Use the

OUTPUT_FORMAT

option to control the format of the output file and the

OUTPUT_LENGTH

option to control truncation. For example, the following

commands set the format to ASCII text and does not truncate column contents:

SET OPTION OUTPUT_FORMAT = ‘text’

SET OPTION OUTPUT_LENGTH = 0

Use two

>

characters in a redirection symbol instead of one (for example,

>>#

),

to append the output to the specified file instead of replacing the contents of the
file. Headings are included in the output from the

SELECT

statement if the

output starts at the beginning of the specified file and the output format
supports headings.

Advertising