| Database Toolbox | ![]() |
Get information about primary and foreign keys
Syntax
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 = 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 object.
orcl 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 key.
EMP is the table ftab that contains the foreign key.
The 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, seehttp://java.sun.com/j2se/1.4.2/docs/api/java/sql/ for the
DatabaseMetaData.htmlgetCrossReference property.
See Also
dmd, exportedkeys, get, importedkeys, primarykeys
| confds | database | ![]() |
© 1994-2005 The MathWorks, Inc.