Examples | ARRAY Data Type | Teradata Vantage - Example: Creating an ARRAY Data Type - Advanced SQL Engine - Teradata Database

SQL Data Types and Literals

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-22
dita:mapPath
zsn1556242031050.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1143
lifecycle
previous
Product Category
Teradata Vantageā„¢

The following statement uses Teradata syntax to create a 1-D ARRAY type with 5 elements of type CHAR(10). All elements of the array are initialized to null.

CREATE TYPE phonenumbers_ary AS CHAR(10) ARRAY[5] DEFAULT NULL;

The following statement uses Oracle-compatible syntax to create a 1-D ARRAY type with 5 elements of type CHAR(10). All elements of the array are set to an uninitialized state.

CREATE TYPE phonenumbers_ary AS VARRAY(5) OF CHAR(10);

Consider the following structured UDT:

CREATE TYPE measures_UDT AS(amplitude INTEGER,
                            phase     INTEGER,
                            frequency INTEGER);
The following statement uses Teradata syntax to create a 3-D ARRAY type with elements of type measures_UDT. The scope of this array is composed of three dimensions:
  • Dimension one has a lower bound of 1 and an upper bound of 5.
  • Dimension two has a lower bound of 1 and an upper bound of 7.
  • Dimension three has a lower bound of 1 and an upper bound of 20.
    CREATE TYPE seismic_cube AS measures_UDT ARRAY [1:5][1:7][1:20];

The following statement uses Oracle-compatible syntax to create the same 3-D ARRAY type.

CREATE TYPE seismic_cube AS VARRAY (1:5)(1:7)(1:20) OF measures_UDT;