WITH DELETED ROWS - Teradata Database - Teradata Vantage NewSQL Engine

SQL Data Manipulation Language

Product
Teradata Database
Teradata Vantage NewSQL Engine
Release Number
16.20
Published
March 2019
Language
English (United States)
Last Update
2019-05-03
dita:mapPath
fbo1512081269404.ditamap
dita:ditavalPath
TD_DBS_16_20_Update1.ditaval
dita:id
B035-1146
lifecycle
previous
Product Category
Teradata Vantage™

Include deleted rows in the query processing for a single load isolated table.

Required Privileges

In addition to the SELECT privilege, you must have the DROP TABLE privilege to execute this special read operation on the load isolated table.

If the table is associated with row-level security (RLS) constraints, you must have appropriate row-level security. RLS checks are applied on all rows, including logically deleted rows.

ANSI Compliance

The WITH DELETED ROWS clause is a Teradata extension to the ANSI SQL:2011 standard.

Locking Modifiers and the WITH DELETED ROWS Option

A locking modifier, if specified, is ignored when you specify the WITH DELETED ROWS option.

Join Indexes and the WITH DELETED ROWS Option

You cannot include join indexes in the SELECT statement when you specify the WITH DELETED ROWS option.

Example: Obtain the Total Number of Rows in the Table

    SELECT WITH DELETED ROWS COUNT(*) FROM  ldi_table;

Example: Obtain the Number of Logically Deleted Rows

For information on the TD_ROWLOADID expression, see Inserting into Load Isolated Tables.

    SELECT WITH DELETED ROWS COUNT(*) FROM ldi_table
    WHERE TD_ROWLOADID > '100000000'xi8;

Example: Obtain the Number of Logically Deleted Rows From a Load Operation

For information on the TD_ROWLOADID expression, see Inserting into Load Isolated Tables.

    SELECT WITH DELETED ROWS COUNT(*) FROM  ldi_table 
    WHERE (TD_ROWLOADID/'100000000'xi8)(int) =  load_id_value;