17.05 - Example: Adding or Dropping a Batch Referential Constraint - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Definition Language Syntax and Examples

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
Release Date
January 2021
Content Type
Programming Reference
Publication ID
B035-1144-175K
Language
English (United States)

This example first adds a table-level batch referential constraint to column d1 in table drs.t2 referencing column c1 in table drs.t1 and then drops that same constraint.

     CREATE SET TABLE drs.t1, NO FALLBACK, NO BEFORE JOURNAL,
                              NO AFTER JOURNAL (
       c1 INTEGER NOT NULL,
       c2 INTEGER NOT NULL,
       c3 INTEGER NOT NULL)
     UNIQUE PRIMARY INDEX (c1);
     CREATE SET TABLE drs.t2, NO FALLBACK, NO BEFORE JOURNAL,
                              NO AFTER JOURNAL (
       d1 INTEGER,
       d2 INTEGER,
       d3 INTEGER);
     ALTER TABLE drs.t2
      ADD CONSTRAINT fpk1
      FOREIGN KEY (d1) REFERENCES WITH CHECK OPTION drs.t1 (c1);
     ALTER TABLE drs.t2
      DROP FOREIGN KEY (d1) REFERENCES WITH CHECK OPTION drs.t1 (c1);