17.10 - Example: NOS and Nondefault Field Delimiter, Header - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Definition Language Syntax and Examples

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

This example shows how to create a foreign table with a nondefault field delimiter with NOS on (the default) and off. The CSV file has a header and its field delimiter is tab (\t).

rivers.tsv

09379180 LAGUNA CREEK AT DENNEHOTSO, AZ
09379910 COLORADO RIVER BELOW GLEN CANYON DAM, AZ
09380000 COLORADO RIVER AT LEES FERRY, AZ
09382000 PARIA RIVER AT LEES FERRY, AZ
09383300 FILLER DITCH AT GREER, AZ
09383400 LITTLE COLORADO RIVER AT GREER, AZ
09383100 COLORADO R ABV LITTLE COLORADO R NR DESERT VIEW
09379200 CHINLE CREEK NEAR MEXICAN WATER, AZ
09379050 LUKACHUKAI CREEK NEAR LUKACHUKAI, AZ
09379025 CHINLE CREEK AT CHINLE, AZ

Using NOS (Default)

NOS detects the field delimiter. You do not have to specify it.

CREATE FOREIGN TABLE rivers_t,
  EXTERNAL SECURITY MyAuthObj
  USING (
    LOCATION ('/s3/YOUR-BUCKET.s3.amazonaws.com/RIVERS/rivers.tsv')
  );

Not Using NOS

You must specify the field delimiter with ROWFORMAT.

CREATE FOREIGN TABLE rivers_t1,
EXTERNAL SECURITY MyAuthObj 
USING
(
   LOCATION ('/s3/YOUR-BUCKET.s3.amazonaws.com/RIVERS/rivers.tsv')
   ROWFORMAT ('{"field_delimiter":"\t"}')
);