DatabaseLink`
DatabaseLink`

SQLTableImportedKeys

SQLTableImportedKeys[conn,table]

returns information about primary keys referenced by foreign keys in table.

Details and Options

  • To use SQLTableImportedKeys, you first need to load DatabaseLink using Needs["DatabaseLink`"].
  • The following options can be given:
  • "Catalog"Nonedatabase catalog to use
    "Schema"Nonedatabase schema to use
    "ShowColumnHeadings"Falsewhether to return headings with the results

Examples

Basic Examples  (1)

If you find that the examples in this section do not work as shown, you may need to install or restore the example database with the DatabaseLink`DatabaseExamples` package, as described in Using the Example Databases.

Open a connection:

Create a table with a primary key:

Create another table. The PersonId column will be used for a foreign key constraint referencing the PEOPLE table's primary key:

Add the foreign key constraint:

The foreign key appears as an index in the EMPLOYEES table:

The primary key of the PEOPLE table now appears as an imported key of EMPLOYEES: