Inserting selected rows from the database
192
SKIP
number-of-rows
START ROW ID
number
This form of the
INSERT
statement lets you insert any number of rows of data,
based on the results of a general
SELECT
statement.
For maximum efficiency, insert as many rows as possible in one
INSERT
statement. To insert additional sets of rows after the first insert, use additional
INSERT
statements.
Like other SQL databases, Adaptive Server IQ inserts data by matching the
order in which columns are specified in the destination column list and the
select list; that is, data from the first column in the select list is inserted into the
first destination column, and so on. For both
INSERT SELECT
and
INSERT
VALUES
, if you omit destination column names, Adaptive Server IQ inserts
data into columns in the order in which they were created.
The tables you are inserting into must exist in the database you are currently
connected to. Adaptive Server IQ inserts the data into all indexes for the
destination columns. (
The columns in the table in the select-list and in the table must have the same
or compatible data types. In other words, the selection’s value must be, or must
be able to be converted to, the data type of the table’s column. See “Converting
data on insertion” for more information about data types and conversion
options.
With this form of the
INSERT
statement you can specify any of the following
insert-load-options:
The
START ROW ID
option lets you perform a partial-width insert. Read
“Partial-width insertions” before you specify this option.
For an explanation of all of these options, see “Specifying load options”.
Example
This example shows an insert from one table,
partsupp
, to another,
lineitem
,
within the same database. The data from the source column
l_quantity
is
inserted into the destination column
ps_availqty
.
INSERT INTO partsupp(ps_availqty)
SELECT l_quantity FROM lineitem
Inserting from a different database
You can insert data from tables in any accessible database:
Summary of Contents for Adaptive Server IQ 12.4.2
Page 1: ...Administration and Performance Guide Adaptive Server IQ 12 4 2 ...
Page 16: ...xvi ...
Page 20: ...Related documents xx ...
Page 40: ...Compatibility with earlier versions 20 ...
Page 118: ...Troubleshooting startup shutdown and connections 98 ...
Page 248: ...Importing data by replication 228 ...
Page 306: ...Integrity rules in the system tables 286 ...
Page 334: ...Cursors in transactions 314 ...
Page 396: ...Users and permissions in the system tables 376 ...
Page 438: ...Determining your data backup and recovery strategy 418 ...
Page 484: ...Network performance 464 ...
Page 500: ...System utilities to monitor CPU use 480 ...
Page 514: ...Characteristics of Open Client and jConnect connections 494 ...
Page 536: ...Index 516 ...