How it works...

Here, you can use copy stats to your advantage.

Let's create a table with a changed new structure, as shown here (the source and target table definitions should match):

/*DDL for table used*/CREATE SET TABLE cookbook_sandpit.copy_stats_new ,NO FALLBACK ,
     NO BEFORE JOURNAL,
     NO AFTER JOURNAL,
     CHECKSUM = DEFAULT,
     DEFAULT MERGEBLOCKRATIO
     (
      username varCHAR(30) CHARACTER SET LATIN NOT CASESPECIFIC,
      LogDate DATE FORMAT 'YYYY-MM-DD',
            DatabaseName CHAR(30) CHARACTER SET LATIN NOT CASESPECIFIC,
      TotalCpu FLOAT)
PRIMARY INDEX ( username ,logdate  );

This will create an empty table with stats only copied, as follows:

/*COPY statistics*/collect stats on cookbook_sandpit.copy_stats_new from cookbook_sandpit.copy_stats

Now we can replace ...

Get Teradata Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.