Partioning and RI Validation Errors | Teradata Vantage - Solving Partitioning and RI Validation Errors - Advanced SQL Engine - Teradata Database

Database Administration

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-22
dita:mapPath
rgu1556127906220.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1093
lifecycle
previous
Product Category
Teradata Vantage™

You can use the following procedures and tools to detect and correct errors in tables that use partitioning and referencing. (For more information, see “Partitioned and Nonpartitioned Primary Indexes” and “FOREIGN KEY … REFERENCES Constraints” in Teradata Vantage™ - Database Design, B035-1094.)

IF you want to … THEN …
correct a partitioning expression that is causing transaction rollbacks due to an evaluation error (such as divide by zero) do one of the following:
  • Change the partitioning expression
  • Delete the rows causing the problem
  • Remove partitioning from the table
  • Drop the table
find invalid table states or internal structures run the CheckTable utility LEVEL 3 command.
regenerate only the headers in a table with partitioning use the ALTER TABLE … REVALIDATE statement.
validate a column-partitioned table or join index use the REVALIDATE option of the ALTER TABLE request.
for a table with partitioning:
  • Regenerate table headers
  • Re-evaluate partition expressions
  • Recalculate row hash values
  • Move rows to proper AMPs and row partitions
  • Update any SI, JI, and HI defined for the table
use the ALTER TABLE … REVALIDATE WITH DELETE/INSERT[INTO] statement.
  • WITH DELETE deletes any rows with a partition number that is null or outside the valid range.
  • WITH INSERT [INTO] deletes any rows with a partition number that is null or outside the valid range and inserts them into save_table.
REVALIDATE changes the table version.
reset the state of RI tables after an ARC RESTORE operation run the ARC utility REVALIDATE REFERENCES FOR command. For more information, see Teradata® Archive/Recovery Utility Reference, B035-2412.
find corrupt rows after running an update or delete operation using WITH NO CHECK OPTION on tables with RI constraints submit the RI Validation Query, structured as:
SELECT DISTINCTchildtablename .* 
 FROM  childtablename,parenttablename  WHERE childtablename .fkcol   NOT IN (SELECT pkcol FROM parenttablename ) 
 AND childtablename .fkcol IS NOT NULL;

This query reports every row in the Child table with an FK value that does not have a matching PK value. (FK nulls are excluded because it is not possible to determine the values they represent.)

purify a Child table for which corrupt rows were reported by the RI Validation Query delete from the Child table any reported rows as soon as possible to maintain the integrity of your database.