15.00 - Rules for Set Operators - Teradata Database

Teradata Database SQL Functions, Operators, Expressions, and Predicates

Product
Teradata Database
Release Number
15.00
Content Type
Programming Reference
Publication ID
B035-1145-015K
Language
English (United States)

Rules for Set Operators

Duplicate Rows

By default, duplicate rows are not returned.

To permit duplicate rows to be returned, specify the ALL option. For an example, see “Retaining Duplicate Rows Using the ALL Option” on page 1151.

Operations That Support Set Operators

You can use set operators within the following operations:

  • Simple queries
  • Derived tables
  • Note: You cannot use the HASH BY or LOCAL ORDER BY clauses in derived tables with set operators.

  • Subqueries
  • INSERT … SELECT clauses
  • View definitions
  • SELECT statements connected by set operators can include all of the normal clause options for SELECT except the WITH clause.

    SELECT AND CONSUME Statement

    Set operations do not operate on SELECT AND CONSUME statements.

    Support for ORDER BY Clause

    A query expression can include only one ORDER BY specification, at the end.

    Restrictions on the Data Types Involved in Set Operations

    The following restrictions apply to CLOB, BLOB, and UDT types involved in set operations:

     

    Data Type

    Restrictions

    BLOB

    You cannot use set operators with CLOB or BLOB types.

    CLOB

    UDT

  • Multiple UDTs involved in set operations must be identical types because Teradata Database does not perform implicit type conversion on UDTs involved in set operations.
  • A workaround for this restriction is to use CREATE CAST to define casts that cast between the UDTs and then explicitly invoke the CAST function within the set operation.

  • UDTs involved in set operations must have ordering definitions.
  • Teradata Database generates ordering functionality for distinct UDTs where the source types are not LOBs. To create an ordering definition for structured UDTs or distinct UDTs where the source types are LOBs, or to replace system-generated ordering functionality, use CREATE ORDERING.

    For more information on CREATE CAST and CREATE ORDERING, see SQL Data Definition Language.