17.05 - Example: Merging into a Table with an Explicit Isolated Load Operation - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Manipulation Language

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
Release Date
January 2021
Content Type
Programming Reference
Publication ID
B035-1146-175K
Language
English (United States)

For information on defining a load isolated table and performing an explicit isolated load operation, see the WITH ISOLATED LOADING option for CREATE TABLE and ALTER TABLE, in addition to Load Isolation Statements in Teradata Vantage™ - SQL Data Definition Language Syntax and Examples, B035-1144.

Following are the table definitions for the example.

CREATE TABLE ldi_table1,
     WITH CONCURRENT ISOLATED LOADING FOR ALL
     (a INTEGER,
      b INTEGER,
      c INTEGER)
PRIMARY INDEX ( a );


CREATE TABLE t1
     (c1 INTEGER,
      c2 INTEGER,
      c3 INTEGER)
PRIMARY INDEX ( c1 );
This statement starts an explicit concurrent load isolated operation on table ldi_table1:
 BEGIN ISOLATED LOADING ON ldi_table1 
    USING QUERY_BAND 'LDILoadGroup=Load1;';
This statement sets the session as an isolated load session:
SET QUERY_BAND='LDILoadGroup=Load1;' FOR SESSION;
This statement performs an explicit concurrent load isolated merge into table ldi_table1 from table t1:
 MERGE INTO ldi_table1
    USING t1 ON a=c1
    WHEN NOT MATCHED THEN INSERT
    VALUES (c1, c2, c3);
This statement ends the explicit concurrent load isolated operation:
END ISOLATED LOADING FOR QUERY_BAND 'LDILoadGroup=Load1;';
You can use this statement to clear the query band for the next load operation in the same session:
SET QUERY_BAND = 'LDILoadGroup=NONE;' FOR SESSION;