Use INSERT SELECT to Load Data | Native Object Store ( NOS ) | Teradata Vantage - Loading External Data into the Database Using INSERT ... SELECT - Analytics Database - Teradata Vantage

Teradata Vantage™ - Native Object Store Getting Started Guide - 17.20

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-04-05
dita:mapPath
tsq1628112323282.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
jjn1567647976698
Product Category
Teradata Vantage

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. See Setting Up to Run 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 perm_table_name (
    columnX data_type
    ,columnY data_type
    ,columnZ data_type
    ,columnN data_type )
    PRIMARY INDEX (columnN);
  4. Insert the external data into the database table:
    INSERT INTO perm_table_name
    SELECT columnX, columnY, ...columnN
    WHERE columnN = value
    FROM table_name;

Example: Loading External Data into the Database Using INSERT ... SELECT

Create the permanent table to store external data:

CREATE TABLE RiverFlowPermInsert (
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);

Insert the external data FROM the foreign table into the permanent database table. If the foreign table does not exist, create it first. See Setting Up to Run Examples.

INSERT INTO RiverFlowPermInsert
SELECT site_no, Flow, GageHeight, Precipitation, datetime, GageHeight2
WHERE site_no = 9474000
FROM riverflow;

Query the data from the database table:

SELECT TOP 2 * FROM RiverFlowPermInsert;

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.