|  |  | 
|  |  | Archives of the TeradataForumMessage Posted: Mon, 11 Apr 2005 @ 20:55:15 GMT
 
 Since V2R5 the "UNION ALL" has been enhanced to do the following: "................ from am R5 presentation: "......... Each SELECT in the set query must be from a base table. Each SELECT must include all PRIMARY INDEX columns in the same position of the SELECT list. Each set operation must be UNION ALL. I also found this in the doc, but haven't verified if this is still true at R5.1 or R6. ".......... Additionally if could use the CHECK CONSTRAINT operator on a column you could see benefits shown in the example below: 
     2nd quarter
     CREATE TABLE order2 (
           . . .
     CHECK ((EXTRACT(MONTH FROM O_ORDERDATE) >=4) and
            (EXTRACT(MONTH FROM O_ORDERDATE) <=6))
     UNIQUE PRIMARY INDEX ( O_ORDERKEY );
     3rd quarter
     CREATE TABLE order3 (
           . . .
     CHECK ((EXTRACT(MONTH FROM O_ORDERDATE) >=7) and
            (EXTRACT(MONTH FROM O_ORDERDATE) <=9))
     UNIQUE PRIMARY INDEX ( O_ORDERKEY );
     4th quarter
     CREATE TABLE order4  (
           . . .
     CHECK ((EXTRACT(MONTH FROM O_ORDERDATE) >=10) and
            (EXTRACT(MONTH FROM O_ORDERDATE) <=12))
     UNIQUE PRIMARY INDEX ( O_ORDERKEY );
Ordertbl is a union view of all four quarters 
     CREATE VIEW ORDERTBL AS
     SELECT * FROM ORDER1 UNION ALL SELECT * FROM ORDER2 UNION ALL
     SELECT * FROM ORDER3 UNION ALL SELECT * FROM ORDER4;
     SELECT * from ORDERTBL WHERE
         EXTRACT (MONTH FROM O_ORDERDATE) >= 5 AND
         EXTRACT (MONTH FROM O_ORDERDATE) <= 8 ;
This query, that selects orders made between May and August, only accesses Order2 and Order3 tables. Before Teradata Database V2R5.0, this would access all the tables 
 | ||||||||||||||||||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||||||||||||||||||||
| 
 | ||||||||||||||||||||||||||||||||||||||||||||||||
|   | ||||||||||||||||||||||||||||||||||||||||||||||||
| Copyright 2016 - All Rights Reserved | ||||||||||||||||||||||||||||||||||||||||||||||||
| Last Modified: 15 Jun 2023 | ||||||||||||||||||||||||||||||||||||||||||||||||