SQLTableImportedKeys
This feature is not supported on the Wolfram Cloud.

SQLTableImportedKeys[conn]
returns a table of primary key descriptions that are referenced by the table's foreign key.

SQLTableImportedKeys[conn,table]
returns the foreign key descriptions for table.

DetailsDetails

  • 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"Nonewhether to return headings with the results

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

In[1]:=
Click for copyable input

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 package, as described in Using the Example Databases.

Open a connection:

In[2]:=
Click for copyable input

Create a table with a primary key:

In[3]:=
Click for copyable input
Out[3]=

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

In[4]:=
Click for copyable input
Out[4]=

Add the foreign key constraint:

In[5]:=
Click for copyable input
Out[5]=

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

In[6]:=
Click for copyable input
Out[6]//TableForm=

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

In[7]:=
Click for copyable input
Out[7]//TableForm=
In[8]:=
Click for copyable input
Out[8]=
In[9]:=
Click for copyable input
Out[9]=
In[10]:=
Click for copyable input