15.00 - Rules for Set Operators - Teradata Database

Teradata Database SQL Functions, Operators, Expressions, and Predicates

Teradata Database
Release Number
Content Type
Programming Reference
Publication ID
English (United States)
Last Update

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.


    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



    You cannot use set operators with CLOB or BLOB types.



  • 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.