Sei sulla pagina 1di 1

64 Chapter 2: Inserting

BEGIN
DECLARE LOCAL TEMPORARY TABLE temp_t1 (
key_1 INTEGER NOT NULL,
col_2 INTEGER NOT NULL,
PRIMARY KEY ( key_1 ) )
NOT TRANSACTIONAL;
LOAD TABLE temp_t1 FROM 't1_d.txt';
INSERT t1 SELECT * FROM temp_t1;
END;
Now the individual inserted rows are recorded in the transaction log. Here is
what the output from dbtran.exe looks like:
--INSERT-1001-0000475402
INSERT INTO DBA.t1(key_1,col_2)
VALUES (1,1)
go
--INSERT-1001-0000475411
INSERT INTO DBA.t1(key_1,col_2)
VALUES (2,2)
go
Note that operations involving temporary tables are not recorded in the transac-
tion log, and with the NOT TRANSACTIONAL clause they arent recorded in
the rollback log either. That means the LOAD TABLE statement isnt written to
the transaction log, the rows it inserts arent written to the rollback log, and it
doesnt cause a commit or a checkpoint; the speed disadvantage of this tech-
nique might not be so bad after all. For more information about temporary
tables, see Section 1.15 in Chapter 1, Creating.

2.4 ISQL INPUT


The Interactive SQL utility (dbisql.exe, or ISQL) supports a statement that
looks similar to LOAD TABLE but is profoundly different in many respects
the ISQL INPUT statement.
The ISQL INPUT statement comes in three formats. The first format uses
the FROM option to read data from a file. The second format uses the PROMPT
option to initiate an interactive dialog for manual entry of individual column
values, one row at a time. The third format uses neither FROM nor PROMPT
but reads lines of text that appear inline immediately following the INPUT
statement, either in the ISQL SQL Statements pane or in the command file con-
taining the INPUT statement. Processing of inline data is terminated by the
keyword END all by itself on one line, with no semicolon, or by the physical
end of input.
The syntax for all three formats is presented here, but only the first format,
using the FROM clause, will be discussed further. The other two formats are
handy for small amounts of data but are not appropriate for loading large tables.
<isql_input> ::= <isql_input_from_file>
| <isql_input_with_prompt>
| <isql_inline_input>
<isql_input_from_file> ::= INPUT <file_input_option_list>
<isql_input_with_prompt> ::= INPUT <prompt_input_option_list>
<isql_inline_input> ::= INPUT <inline_input_option_list>
<inline_data>
<end_of_input_marker>
<file_input_option_list> ::= <input_option_list> including FROM option

Potrebbero piacerti anche