CREATE FOREIGN TABLE Statement | Teradata Vantage - 17.00 - Example: Creating a Foreign Table with Default Columns and Options - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Definition Language Syntax and Examples

Product
Advanced SQL Engine
Teradata Database
Release Number
17.00
Release Date
September 2020
Content Type
Programming Reference
Publication ID
B035-1144-170K
Language
English (United States)

This example creates the foreign table sensordata by specifying only the required table_name and LOCATION parameters.

CREATE FOREIGN TABLE sensordata 
USING (
       LOCATION ('/S3/YOUR-BUCKET.s3.amazonaws.com/data')
 );

This results in a table definition with the default Location and Payload columns, in addition to default values for the remaining options.

SHOW TABLE sensordata;
CREATE MULTISET FOREIGN TABLE D1.sensordata 
,FALLBACK 
,MAP = TD_MAP1 ( 
    Location VARCHAR(2048) CHARACTER SET UNICODE CASESPECIFIC, 
    Payload JSON(8388096) INLINE LENGTH 32000 CHARACTER SET UNICODE) 
USING (
    LOCATION ('/S3/YOUR-BUCKET.s3.amazonaws.com/data') 
    PATHPATTERN ('$Var1/$Var2/$Var3/$Var4/$Var5/$Var6/$Var7/$Var8/$Var9/$Var10
    /$Var11/$Var12/$Var13/$Var14/$Var15/$Var16/$Var17/$Var18/$Var19/$Var20') 
    ROWFORMAT ('{"record_delimiter":"\n", "character_set":"UTF8"}') 
    STOREDAS ('TEXTFILE') 
) 
NO PRIMARY INDEX ;