15.10 - Example: Adding or Dropping a Batch Referential Constraint - Teradata Database

Teradata Database SQL Data Definition Language Syntax and Examples

prodname
Teradata Database
vrm_release
15.10
created_date
December 2015
category
Programming Reference
featnum
B035-1144-151K

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