Examples - Teradata Vantage - Analytics Database

SQL Data Definition Language Syntax and Examples

Deployment
VantageCloud
VantageCore
Edition
VMware
Enterprise
IntelliFlex
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2025-11-06
dita:mapPath
jco1628111346878.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
mdr1472255012272
lifecycle
latest
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 following example, 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. Because the preceding 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);