Use INSERT SELECT to Load CSV | Native Object Store ( NOS ) | Teradata Vantage - 17.10 - Loading External Data into the Database Using INSERT ... SELECT - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - Native Object Store Getting Started Guide

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1214-171K
Language
English (United States)

This example illustrates how a single siteno value can be stored in a persistent database table using an INSERT ... SELECT statement.

The examples use a sample river flow data set. To use your own data, replace the table and column names, and authorization object. See Variable Substitutions for Examples for the credentials and location values for the sample data set.

  1. To run NOS-related commands, log on to the database as a user with the required privileges.
  2. If it does not exist, create the foreign table or ask your database administrator to create the foreign table called riverflow_csv. See Setting Up to Run CSV Examples.
  3. In this example, data from a single site number is loaded into the database. Create the permanent table to store the external data:
    CREATE TABLE RiverFlowPermInsert_csv (
    SiteNo INTEGER
    ,Flow DECIMAL(3,2)
    ,GageHeight DECIMAL(3,2)
    ,Precipitation DECIMAL(3,2)
    ,datetime TIMESTAMP(0) FORMAT'Y4-MM-DDBHH:MI'
    ,GageHeight2 DECIMAL(3,2) )
    PRIMARY INDEX (SiteNo);
  4. Insert the external data into the database table:
    INSERT INTO RiverFlowPermInsert_csv
    SELECT site_no, Flow, GageHeight, Precipitation, datetime, GageHeight2
    WHERE site_no = 9474000
    FROM riverflow_csv;
  5. Query the data from the database table:
    SELECT TOP 2 * FROM RiverFlowPermInsert_csv;

    Your result will be similar to the following:

           SiteNo      9474000
             Flow    .80
       GageHeight   3.51
    Precipitation    .00
         datetime  2018-07-26 01:00
      GageHeight2   6.66
    
           SiteNo      9474000
             Flow    .80
       GageHeight   3.51
    Precipitation    .00
         datetime  2018-07-26 00:30
      GageHeight2   6.66
    

    The output is displayed vertically for readability.