Triggers and Referential Integrity - Teradata VantageCloud Lake

Lake - Working with SQL

Deployment
VantageCloud
Edition
Lake
Product
Teradata VantageCloud Lake
Release Number
Published
February 2025
ft:locale
en-US
ft:lastEdition
2025-11-21
dita:mapPath
jbe1714339405530.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
jbe1714339405530
The following trigger cases return a referential integrity violation error to the requestor for all forms of referential integrity:
  • The triggering statement is an UPDATE on the child table in the relationship.
  • The triggering statement is a DELETE on child table in the relationship.
  • The triggers are cascaded.
The following trigger cases for tables with referential integrity relationships are valid if and only if the relationship is defined using batch referential integrity (see Batch Referential Integrity Constraints):
  • The triggering statement is a DELETE operation on the parent table in the relationship.
  • The triggering statement is an UPDATE operation on the parent table in the relationship.
  • The triggering statement is an INSERT operation on the child table in the relationship.
  • The triggering statement is an INSERT operation on the child table in the relationship and defines an INSERT … SELECT operation as the triggered action statement.
  • For cascaded triggers, the system only handles INSERT operations as the triggering statement. For example, an INSERT operation on the parent table and an INSERT on the child table in the relationship.

    No other cascaded triggers are valid.

The following table definitions define tables that make up a referential integrity checking hierarchy. Batch RI is defined on tables child_tab (referring to parent_tab) and grandchild_tab (referring to child_tab).

The foreign keys for these tables are defined implicitly using REFERENCES clauses without specifying FOREIGN KEY, but the referential integrity checking defined is the same as if the keywords FOREIGN KEY had been specified.

Triggers are defined on these tables.

     CREATE TABLE parent_tab (
       prime_key INTEGER NOT NULL,
       column_2  INTEGER,
       null_col  CHARACTER DEFAULT NULL)
     UNIQUE PRIMARY INDEX (prime_key);

     CREATE TABLE child_tab ( 
       prime_key INTEGER NOT NULL,
       null_col  CHARACTER DEFAULT NULL,
       for_key   INTEGER REFERENCES WITH CHECK OPTION parent_tab
                 (prime_key))
     UNIQUE PRIMARY INDEX (prime_key);

     CREATE TABLE grandchild_tab ( 
       prime_key INTEGER NOT NULL,
       column_3  INTEGER,
       grc_key   INTEGER REFERENCES WITH CHECK OPTION child_tab
                 (prime_key))
     UNIQUE PRIMARY INDEX (prime_key);

Consider the following definitions of the referential levels among these tables and the respective triggering statements that are supported:

Level Triggering Statement Table in RI Relationship
1 DELETE or UPDATE Parent
2 DELETE or UPDATE Child

There are batch referential integrity relationships between the table pairs as listed in the following table:

Level Tables with Batch Referential Integrity Relationship
1
  • parent_tab
  • child_tab
2
  • child_tab
  • grandchild_tab