Sybase 12.4.2 manual 194

Models: 12.4.2

1 536
Download 536 pages 20.34 Kb
Page 214
Image 214

Inserting selected rows from the database

Example

Importing data from pre-Version 12 Adaptive Server IQ

LOCATION ’detroit.asiq11db’

{SELECT l_shipdate, l_orderkey FROM lineitem }

The destination and source columns may have different names.

The order in which you specify the columns is important, because data from the first source column named is inserted into the first target column named, and so on.

You can use the predicates of the SELECT statement within the INSERT command to insert data from only certain rows in the table.

This example inserts the same columns as the previous example, but only for the rows where the value of l_orderkey is 1.

INSERT INTO lineitem (l_shipdate, l_orderkey) LOCATION ’detroit.asiqdb’

{SELECT l_shipdate, l_orderkey FROM lineitem

WHERE l_orderkey = 1 }

Note If you use START ROW ID and you select fewer columns than exist in the destination table, the columns in remaining rows of the destination table will be NULLs, if NULLs are legal values. See “Partial-width insertions” for more information.

To import data from an Adaptive Server IQ database version earlier than 12.0, you must use of the following methods:

The LOAD TABLE command with the UNLOAD FORMAT option.

The INSERT...LOCATION syntax

You cannot use other forms of the INSERT command.

For more information on loading from an older version, see the Adaptive Server IQ Installation and Configuration Guide.

194

Page 214
Image 214
Sybase 12.4.2 manual 194