17.05 - Example: Identity Columns and INSERT … SELECT - 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)

Assume that column_1 of table_1 is a GENERATED BY DEFAULT identity column.

     INSERT INTO table_2 (column_1, column_2, column_3)
       VALUES (111,111,111);
     INSERT INTO table_2 (column_1, column_2, column_3)
       VALUES (222,222,222);
     INSERT INTO table_2 (column_1, column_2, column_3)
       VALUES (1,333,333);

     INSERT INTO table_1 (column_1, column_2, column_3)
     SELECT * FROM table_2;

Check the result of the insert operations by selecting all the rows from table_1.

     SELECT *
     FROM table_1;
     *** Query completed. 3rows found. 3 columns returned.
     *** Total elapsed time was 1 second.
      column_1  column_2  column_3
     --------- --------- ---------
           111       111       111
           222       222       222
             1       333       333