Examples - Advanced SQL Engine - Teradata Database

SQL Data Definition Language Syntax and Examples

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
Published
January 2021
Language
English (United States)
Last Update
2021-01-22
dita:mapPath
ncd1596241368722.ditamap
dita:ditavalPath
hoy1596145193032.ditaval
dita:id
B035-1144
lifecycle
previous
Product Category
Teradata Vantage™

Specifying a Sparse Map and Colocation Name for a Table

In this example, the table creator has been granted the sparse maps FourAMP_Map, with AMPCount = 4, and TenAMP_Map, with AMPCount = 10. The colocation name defaults to MyDatabase_Table1.

CREATE TABLE MyDatabase.Table1, MAP=FourAMP_Map 
(a1 INTEGER, b1 INTEGER) UNIQUE PRIMARY INDEX (a1);

In the example below, the colocation name is explicitly specified. Even though this table has the same colocation name as the previous table, the tables are not colocated because each table definition specifies a different sparse map. To avoid confusion, you should specify a different colocation name for tables that use different sparse maps.

CREATE TABLE AnotherTable, 
Map=TenAMP_Map COLOCATE USING MyDatabase_Table1
(a3 INTEGER, d3 INTEGER) PRIMARY INDEX (a3);

Specifying a Colocation Name for Tables

The table creator has been granted the sparse map, TenAMP_Map, with AMPCOUNT=10. The colocation name is MyGroups_Group4.

CREATE TABLE MyDatabase1.Orders
, MAP=TenAMP_Map COLOCATE USING MyGroups_Group4
(a1 INTEGER, b1 INTEGER) UNIQUE PRIMARY INDEX (a1);

The colocation name is also MyGroups_Group4 for this table. Since the above two tables have the same map, colocation name, and primary index data type, they can be directly joined on their primary indexes without redistribution.

CREATE TABLE MyDatabase2.LineItems
, Map=TenAMP_Map COLOCATE USING MyGroups_Group4
(a2 INTEGER, c2 INTEGER) PRIMARY INDEX (a2);