Extract Options

The extract options let you redirect the output of a SELECT statement from the standard interface to go directly to one or more disk files or named pipes.

Option Name

Allowed Values

Default value

Temp_Extract_Append

ON or OFF

OFF

Temp_Extract_Binary

ON or OFF

OFF

Temp_Extract_Column_Delimiter

String

','

Temp_Extract_Directory

String

''

Temp_Extract_Name1

String

''

Temp_Extract_Name2

String

''

Temp_Extract_Name3

String

''

Temp_Extract_Name4

String

''

Temp_Extract_Name5

String

''

Temp_Extract_Name6

String

''

Temp_Extract_Name7

String

''

Temp_Extract_Name8

String

''

Temp_Extract_Null_As_Empty

ON or OFF

OFF

Temp_Extract_Null_As_Zero

ON or OFF

OFF

Temp_Extract_Quote

String

''

Temp_Extract_Quotes

ON or OFF

OFF

Temp_Extract_Quotes_All

ON or OFF

OFF

Temp_Extract_Row_Delimiter

String

''

Temp_Extract_Size1

Platform specific*

0

Temp_Extract_Size2

Platform specific*

0

Temp_Extract_Size3

Platform specific*

0

Temp_Extract_Size4

Platform specific*

0

Temp_Extract_Size5

Platform specific*

0

Temp_Extract_Size6

Platform specific*

0

Temp_Extract_Size7

Platform specific*

0

Temp_Extract_Size8

Platform specific*

0

Temp_Extract_Swap

ON or OFF

OFF

*The default values for the TEMP_EXTRACT_SIZEn options are platform specific:
  • AIX and HP-UX: 0 – 64GB

  • Sun Solaris: 0 – 512GB

  • Windows: 0 – 128GB

  • Linux: 0 – 512GB

When large file systems, such as JFS2, support file sizes larger than the default value, set TEMP_EXTRACT_SIZEn to the maximum value that the file system allows. For example, to support 1TB set option, enter:
SET OPTION TEMP_EXTRACT_SIZE1 = 1073741824 KB
Note: For all database options that accept integer values, SAP Sybase IQ truncates any decimal option-value setting to an integer value. For example, the value 3.8 is truncated to 3.

The most important of these options is TEMP_EXTRACT_NAME1; if it is set to its default setting (the empty string), extraction is disabled and no output is redirected. To enable extraction, set TEMP_EXTRACT_NAME1 to a path name. Choose a path and file name that are not otherwise in use. If the file does not already exist, the data extraction facility creates the file.

Both the directory / folder containing the named file, and the named file itself, must have write permission set for the user who started IQ (for example, sybase). In append mode, the data extraction facility adds extracted rows to the end of the file and does not overwrite the data that is already in the file.

Warning!  If you choose the path name of an existing file and the TEMP_EXTRACT_APPEND option is OFF (the default), file contents are overwritten.

Use the options TEMP_EXTRACT_NAME2 through TEMP_EXTRACT_NAME8 to specify the names of multiple output files. You must use options sequentially. For example, TEMP_EXTRACT_NAME3 has no effect unless both TEMP_EXTRACT_NAME1 and TEMP_EXTRACT_NAME2 are already set.

Use TEMP_EXTRACT_SIZE1 through TEMP_EXTRACT_SIZE8 to specify the maximum size of the corresponding output files. TEMP_EXTRACT_SIZE1 specifies the maximum size of the output file specified by TEMP_EXTRACT_NAME1, TEMP_EXTRACT_SIZE2 specifies the maximum size of the output file specified by TEMP_EXTRACT_NAME2, and so on.

The default minimum for the data extraction size options is 0. IQ converts this default to the following values:

Device Type

Size

Disk File

AIX and HP-UX: 0 – 64GB

Sun Solaris & Linux: 0 – 512GB

Windows: 0 – 128GB

Other

Unlimited

TEMP_EXTRACT_APPEND is incompatible with the TEMP_EXTRACT_SIZEn options. If you try to restrict the size of the extract append output file, SAP Sybase IQ reports an error.

If you are extracting to a single disk file or a single named pipe, leave TEMP_EXTRACT_NAME2 through TEMP_EXTRACT_NAME8, and TEMP_EXTRACT_SIZE1 through TEMP_EXTRACT_SIZE8 at their default values.

Note: If the SELECT returns no rows and there is no output to redirect, an empty file of zero length is created. If you specify multiple extract files and there is not enough data to fill all of the files, all of the files are still created.

Controlling Access

The TEMP_EXTRACT_DIRECTORY option controls whether a user is allowed to use the data extraction facility. It also controls the directory into which temporary extraction files are placed and overrides a directory path specified in the TEMP_EXTRACT_NAMEn options.

If the TEMP_EXTRACT_DIRECTORY option is set to the string FORBIDDEN (case-insensitive) for a user, then that user is not allowed to perform data extracts. Any attempt to do so results in the error: You do not have permission to perform Extracts.

If TEMP_EXTRACT_DIRECTORY is set to FORBIDDEN for the PUBLIC role, no one can run data extraction.

If TEMP_EXTRACT_DIRECTORY is set to a valid directory path, temporary extraction files are placed in the specified directory, overriding paths in the TEMP_EXTRACT_NAMEn options.

If TEMP_EXTRACT_DIRECTORY is set to an invalid directory path, an error occurs: File does not exist File: <invalid path>.

If TEMP_EXTRACT_DIRECTORY is blank, then temp extract files are placed in directories according to their specification in TEMP_EXTRACT_NAMEn. If no path is specified as part of TEMP_EXTRACT_NAMEn, the extract files are, by default, placed in the server startup directory.

The TEMP_EXTRACT_DIRECTORY option provides increased security and helps control disk management by restricting the creation of large data extraction files to the directories for which a user has write access. Setting the option requires the SET ANY SYSTEM OPTION system privilege. This option takes effect immediately.

Types of Extraction

Types of data extraction include:
  • Binary

  • Binary/swap

  • ASCII

A binary extraction produces a file with an overall "binary" format and a per-column "binary with null byte" format. You can use a LOAD TABLE statement to load the file.

A binary/swap extraction is the same as a binary extraction, except it is designed to be loaded on another machine with opposite endianness.

An ASCII extraction produces a text file.

The two options Temp_Extract_Binary and Temp_Extract_Swap determine which of the three types of extraction is done:

Type

Temp_Extract_Binary

Temp_Extract_Swap

Binary

ON

OFF

Binary/swap

ON

ON

ASCII

OFF

OFF

The default extraction type is ASCII.

If the data is unloaded using the extraction facility with the TEMP_EXTRACT_BINARY option ON, you must use the LOAD TABLE statement BINARY WITH NULL BYTE parameter for each column when you load the binary data.

Column and Row Delimiters

In an ASCII extraction, the default is to separate column values with commas, and end the row with a newline on UNIX platforms and with a carriage return/newline pair on Windows platforms. The strings are unquoted. If these defaults are unsuitable, change the delimiters, using:
  • Temp_Extract_Column_Delimiter

  • Temp_Extract_Row_Delimiter

  • Temp_Extract_Quote

  • Temp_Extract_Quotes

  • Temp_Extract_Quotes_All

The delimiter must occupy from 1 - 4 bytes and must be valid in the collation order you are using, if you are using a multibyte collation order. Choose delimiters that do not occur in any of the data output strings themselves.

The default for the Temp_Extract_Row_Delimiter option is ' ' (an empty string). IQ converts the empty string default for this option to the newline on UNIX platforms and to the carriage return/newline pair on Windows platforms.

The option Temp_Extract_Column_Delimiter controls the delimiter between columns. If this option is set to an empty string for ASCII extractions, the extracted data is written in fixed-width ASCII with no column delimiter. Numeric and binary data types are right-justified on a field of n blanks, where n is the maximum number of bytes needed for any value of that type. Character data types are left-justified on a field of n blanks.

Note: The minimum column width in a fixed-width ASCII extraction is four bytes to allow the string “NULL” for a NULL value. For example, if the extracted column is CHAR(2) and Temp_Extract_Column_Delimiter is set to the empty string, there are two spaces after the extracted data.

During ASCII extraction, these control the use of quotes:

Option

ASCII Extraction Action

Temp_Extract_Quotes

String fields enclosed in quotes

Temp_Extract_Quotes_All

All fields enclosed in quotes

Temp_Extract_Quote

Specifies string to be used as the quote

The quote string specified in the Temp_Extract_Quote option has the same restrictions as delimiters. The default for this option is the empty string, which IQ converts to the single quote mark.

Representation of Null Values

TEMP_EXTRACT_NULL_AS_ZERO and TEMP_EXTRACT_NULL_AS_EMPTY control the representation of null values for ASCII extractions. When TEMP_EXTRACT_NULL_AS_ZERO is set to ON, a null value is represented as follows:
  • '0' for arithmetic type

  • ' ' (the empty string) for the CHAR and VARCHAR character types

  • ' ' (the empty string) for dates

  • ' ' (the empty string) for times

  • ' ' (the empty string) for timestamps

When TEMP_EXTRACT_NULL_AS_EMPTY is set to ON, a null value is represented as ' ' (the empty string) for all data types.

The quotes shown above are not present in the extract output file. When TEMP_EXTRACT_NULL_AS_ZERO and TEMP_EXTRACT_NULL_AS_EMPTY are set to OFF (the default value), the string 'NULL' is used in all cases to represent a NULL value.

If TEMP_EXTRACT_NULL_AS_ZERO is ON, the number of characters that an ASCII extract writes to a file for a CHAR or VARCHAR column equals the number of characters in the column, even if that number is fewer than four.

Message Logging

When the Query_Plan option is ON, a timestamped list of the extracted columns appears in the IQ message log.

Related tasks
Enabling Data Extraction Options