Database Toolbox Previous page   Next Page
importedkeys

Get information about imported foreign keys

Syntax

Description

i = importedkeys(dbmeta, 'cata', 'sch') returns the foreign imported key information, that is, information about fields that reference primary keys in other tables, in the schema sch, of the catalog cata, for the database whose database metadata object is dbmeta, where dbmeta was created using dmd.

i = importedkeys(dbmeta, 'cata', 'sch', 'tab') returns the foreign imported key information, that is, information about fields in the table tab, that reference primary keys in other tables, in the schema sch, of the catalog cata, for the database whose database metadata object is dbmeta, where dbmeta was created using dmd.

Examples

Type

MATLAB returns

In this example:

The results show the foreign imported key information as described in the following table.

Column
Description
Value
1
Catalog containing primary key, referenced by foreign imported key
orcl
2
Schema containing primary key, referenced by foreign imported key
SCOTT
3
Table containing primary key, referenced by foreign imported key
DEPT
4
Column name of primary key, referenced by foreign imported key
DEPTNO
5
Catalog that has foreign imported key
orcl
6
Schema that has foreign imported key
SCOTT
7
Table that has foreign imported key
EMP
8
Foreign key column name, that is the column name that references the primary key in another table
DEPTNO
9
Sequence number within foreign key
1
10
Update rule, that is, what happens to the foreign key when the primary key is updated
null
11
Delete rule, that is, what happens to the foreign key when the primary key is deleted
1
12
Foreign imported key name
FK_DEPTNO
13
Primary key name in referenced table
PK_DEPT

In the schema SCOTT there is only one foreign imported key. The table EMP contains a field, DEPTNO, that references the primary key in the DEPT table, the DEPTNO field. EMP is the referencing table and DEPT is the referenced table. DEPTNO is a foreign imported key in the EMP table. Reciprocally, the DEPTNO field in the table DEPT is an exported foreign key, as well as being the primary key.

For a description of the codes for update and delete rules, see
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/DatabaseMetaData.html for the getImportedKeys property.

See Also
crossreference, dmd, exportedkeys, get, primarykeys


Previous page  get indexinfo Next page

© 1994-2005 The MathWorks, Inc.