Example: Identity Columns and INSERT … SELECT - Teradata Database - Teradata Vantage NewSQL Engine

SQL Data Manipulation Language

Product
Teradata Database
Teradata Vantage NewSQL Engine
Release Number
16.20
Published
March 2019
Language
English (United States)
Last Update
2019-05-03
dita:mapPath
fbo1512081269404.ditamap
dita:ditavalPath
TD_DBS_16_20_Update1.ditaval
dita:id
B035-1146
lifecycle
previous
Product Category
Teradata Vantage™

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