17.10 - Create View of Foreign Table - 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 statement defines a view that includes selected columns cast to appropriate data types.

CREATE VIEW riverflow_csv_v AS (
  SELECT
  CAST(datetime AS VARCHAR(20)) datetime,
  CAST(site_no AS CHAR(8)) Site_no,
  CAST(Flow AS FLOAT) Flow,
  CAST(GageHeight AS FLOAT) GageHeight,
  CAST(GageHeight2 AS FLOAT) GageHeight2,
  CAST(Precipitation AS FLOAT) Precipitation
  FROM riverflow_csv
);

The following statement shows the new view:

SELECT * FROM riverflow_csv_v;
 
datetime          Site_no                    Flow              GageHeight  GageHeight2          Precipitation
----------------  --------  ---------------------  ----------------------  -----------  ---------------------
2018-06-29 00:00  9400815   0.00000000000000E 000  -1.00000000000000E-002            ?  0.00000000000000E 000
2018-07-02 14:35  9429070                       ?                       ?            ?  1.16000000000000E 000
2018-07-01 00:00  9400815   0.00000000000000E 000  -1.00000000000000E-002            ?  0.00000000000000E 000
2018-07-02 00:00  9400815   0.00000000000000E 000  -1.00000000000000E-002            ?  0.00000000000000E 000
2018-07-12 00:00  9400815   0.00000000000000E 000  -1.00000000000000E-002            ?  0.00000000000000E 000
2018-07-10 00:00  9400815   0.00000000000000E 000  -1.00000000000000E-002            ?  0.00000000000000E 000
2018-07-09 00:00  9400815   0.00000000000000E 000  -1.00000000000000E-002            ?  0.00000000000000E 000
2018-07-08 00:00  9400815   0.00000000000000E 000  -1.00000000000000E-002            ?  0.00000000000000E 000
2018-06-29 00:15  9400815   0.00000000000000E 000  -1.00000000000000E-002            ?  0.00000000000000E 000
2018-07-02 14:36  9429070                       ?                       ?            ?  1.09000000000000E 000