Example: Copying Statistics from a Source Table to an Identical Target Table - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

When you copy base table statistics from a source table to an identical target table, the database also copies the USING options from the source to the target by default. You cannot modify the USING options for the source table as part of a copy operation.

When you copy PARTITION statistics, the statistics copied to the target table may not correctly represent the data in the target table because of differences in internal partition number mapping between the source and target tables. This is true even if the table definitions returned by a SHOW TABLE request are identical and the data is the same in both tables.

Recollect the PARTITION statistics for the target table when copied from a source table.

The copy operation implicitly copies the object-level demographics from the source table to the target table.

The following COLLECT STATISTICS requests copy all the statistics from orders to orders_new, which has the same definition as orders. The database copies the corresponding USING options to orders_new and the statistics.

COLLECT STATISTICS ON orders_new
FROM orders;

COLLECT STATISTICS USING SYSTEM SAMPLE
COLUMN o_orderkey
ON orders;