17.05 - Examples - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Definition Language Syntax and Examples

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

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);