In Teradata the definition of a clustered table is very simple and exists in a single syntax (correct me if I'm wrong).
CREATE TABLE table_name (charcol1 varchar(10), idcol integer)
primary index (idcol);
I am reading that there are a whole number of "clustered" table types in DB2 with respect to creating a share-nothing physical data layout for the object.
Defined primary index in TD will spread the table data across all nodes/virtual cpus available to the TD server.
What is the closest method (and syntax) to achieve the same within DB2?
Tables are created in tablespaces, tablespaces are created in database partition groups (or sets of nodes, which you can create as you want) in Db2 for LUW.
You may use the following query to understand which tablespaces reside in which database partition groups.
Let's say you get the following result:
This means that if you run the following statement, then the table is created in a tablespace
USERSPACE1
which resides on database partitions (nodes) 0-3, and table data is distributed between these nodes based on a hash value computed on values ofYEAR
column.It's always advisable to specify a tablespase explicitly, unless the rules of choosing such a tablespace which Db2 uses in case of absence of such a specification are applicable for your particular statement.