DatabaseLink`
DatabaseLink`

SQLTableExportedKeys

SQLTableExportedKeys[conn,table]

returns information about foreign keys that reference the primary key of table.

Details and Options

  • To use SQLTableExportedKeys, 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 column in the "PEOPLE" table now appears as an exported key: