16.20 - Example: Adding or Dropping a Batch Referential Constraint - Teradata Database - Teradata Vantage NewSQL Engine

Teradata Vantage™ SQL Data Definition Language Syntax and Examples

Product
Teradata Database
Teradata Vantage NewSQL Engine
Release Number
16.20
Published
March 2019
Language
English (United States)
Last Update
2019-05-24
dita:mapPath
wkf1512081455740.ditamap
dita:ditavalPath
TD_DBS_16_20_Update1.ditaval

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);