Example documentationFOREIGNKEYS Locate this document in the navigation structure

 

Use of the system table DOMAIN.FOREIGNKEYS

Prerequisites

You can use the demo data for the SQL tutorial. Start the Database Studio as database administrator MONA with the password RED and log on to demo database DEMODB: Logging On to a Database.

Create referential constraints. Proceed as described in SQL Tutorial, Foreign Key Dependencies Between Tables.

Activities

You can use Database Studio to enter and execute SQL statements. More information: Working with SQL Statements: Overview

Note the General Instructions for formulating SQL statements.

You can use the system table FOREIGNKEYS to determine the following database information, among other things:

  • All referential constraints in which the RESERVATION table is the referencing table

    SELECT fkeyname, tablename

    FROM DOMAIN.FOREIGNKEYS

    WHERE tablename = 'RESERVATION'

  • All referential constraints generated with the DELETE CASCADE rule

    SELECT schemaname, fkeyname

    FROM DOMAIN.FOREIGNKEYS

    WHERE rule = 'DELETE CASCADE'

More Information

Columns in a referential constraint: see FOREIGNKEYCOLUMNS