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

SQL Data Definition Language Syntax and Examples

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
Published
January 2021
Language
English (United States)
Last Update
2021-01-22
dita:mapPath
ncd1596241368722.ditamap
dita:ditavalPath
hoy1596145193032.ditaval
dita:id
B035-1144
lifecycle
previous
Product Category
Teradata Vantage™

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