Example: Using the RANDOM Option to Randomly Redistribute Data Blocks of Rows and Individual Rows Before Copying Them Locally - Teradata Database

SQL Data Manipulation Language

Product
Teradata Database
Release Number
15.10
Language
English (United States)
Last Update
2018-10-06
dita:id
B035-1146
lifecycle
previous
Product Category
Teradata® Database

Example: Using the RANDOM Option to Randomly Redistribute Data Blocks of Rows and Individual Rows Before Copying Them Locally

Assume that you created the following NoPI tables for this example.

     CREATE TABLE tnopi1 (
       a INT, 
       b INT, 
       c INT) 
     NO PRIMARY INDEX;
 
     CREATE TABLE tnopi2 (
       a INT, 
       b INT, 
       c INT) 
     NO PRIMARY INDEX;

The following INSERT …  SELECT request uses the RANDOM option to redistribute data blocks of rows randomly from tnopi1 before locally copying them into tnopi2.

     INSERT INTO tnopi2 
       SELECT * 
       FROM tnopi1 
       HASH BY RANDOM;

The following INSERT …  SELECT request uses the RANDOM function to redistribute individual rows randomly from tnopi1 before locally copying them into tnopi2:

     INSERT INTO tnopi2 
       SELECT * 
       FROM tnopi1 
       HASH BY RANDOM(1, 2000000000);
  • “Scalar Subqueries” on page 124
  • “MERGE” on page 405
  • SQL Functions, Operators, Expressions, and Predicates
  • “CREATE ERROR TABLE” in SQL Data Definition Language
  • ANSI Temporal Table Support
  • Temporal Table Support
  • SQL Geospatial Types
  • Database Administration
  • Utilities
  • Teradata FastLoad Reference
  • Teradata MultiLoad Reference
  • Teradata Parallel Data Pump Reference