15.10 - Example: Statistics Are Not Copied If a Join Operation Is Specified in the Subquery - Teradata Database

Teradata Database SQL Data Definition Language Syntax and Examples

prodname
Teradata Database
vrm_release
15.10
created_date
December 2015
category
Programming Reference
featnum
B035-1144-151K

Teradata Database does not copy statistics if a join operation is specified in the subquery. as the examples in this set demonstrate.

Consider the following view definitions for the examples in this set.

    CREATE VIEW v2 (i, j) AS (
      SELECT SUM(x), y 
      FROM test 
      GROUP BY 2);
    CREATE VIEW v3 (i, j) AS (
      SELECT CASE 
             WHEN z1='abc' 
             THEN 1 
             ELSE 0, a1+1 
      FROM test1);

Example1

In this example, Teradata Database does not copy statistics because of the join specification in the subquery.

    CREATE TABLE t4 AS (SELECT *
                        FROM test, test1) 
    WITH DATA AND STATISTICS 
    PRIMARY INDEX (z, z1) 
    INDEX (b, b1);

Example2

In this example, Teradata Database does not copy statistics because of the join specification in the subquery.

    CREATE TABLE t6 (c1, c2, c3, c4) AS (SELECT x1, y1, x-1, y*2
                                         FROM test1, test) 
    WITH DATA AND STATISTICS;

Example3

In this example, Teradata Database does not copy statistics because of the join specification in the subquery.

    CREATE TABLE t5 AS (SELECT *
                        FROM v2, v3) 
    WITH DATA AND STATISTICS;

Example4

In this example, Teradata Database does not copy statistics because of the join specification in the subquery.

    CREATE TABLE t5 AS (SELECT *
                        FROM v3, test) 
    WITH DATA AND STATISTICS;