Database Toolbox | ![]() ![]() |
Get information about primary and foreign keys
Syntax
f = crossreference(dbmeta, 'pcata', 'psch', 'ptab', 'fcata', 'fsch', 'ftab')
Description
f = crossreference(dbmeta, 'pcata', 'psch', 'ptab', 'fcata', 'fsch',
'ftab')
returns information about the relationship between foreign keys and primary keys. Specifically, the information is for the database whose database metadata object is dbmeta
, where dbmeta
was created using dmd
. The primary key information is for the table ptab
, in the primary schema psch
, of the primary catalog pcata
. The foreign key information is for the foreign table ftab
, in the foreign schema fsch
, of the foreign catalog fcata
.
Examples
f = crossreference(dbmeta,'orcl','SCOTT','DEPT',... 'orcl','SCOTT','EMP')
f = Columns 1 through 7 'orcl' 'SCOTT' 'DEPT' 'DEPTNO' 'orcl' 'SCOTT' 'EMP' Columns 8 through 13 'DEPTNO' '1' 'null' '1' 'FK_DEPTNO' 'PK_DEPT'
dbmeta
is the database metadata objectorcl
is the catalog pcata
and the catalog fcata
SCOTT
is the schema psch
and the schema fsch
DEPT
is the table ptab
that contains the referenced primary keyEMP
is the table ftab
that contains the foreign keyThe results show the primary and foreign key information
In the schema SCOTT
, there is only one foreign key. The table DEPT
contains a primary key DEPTNO
that is referenced by the field DEPTNO
in the table EMP
. DEPTNO
in the EMP
table is a foreign key.
For a description of the codes for update and delete rules, see
http://java.sun.com/products/jdk/1.2/docs/api/java/sql/package-summary.html for the DatabaseMetaData
object property getCrossReference
.
See Also
dmd
, exportedkeys
, get
, importedkeys
, primarykeys
![]() | confds | database | ![]() |