The FOREIGN_KEYS rowset identifies the foreign key columns defined in the catalog by a given user. This schema rowset is built upon several SQL92 schema views as a convenience to the non-SQL programmer, and, if supported, this must be synchronized with the related SQL92 views (REFERENTIAL_CONSTRAINTS and CONSTRAINT_COLUMN_USAGE).
The FOREIGN_KEYS rowset contains the following columns
Column name | Type indicator | Description |
PK_NAME | DBTYPE_WSTR | Primary key name. NULL if the provider does not support named primary key constraints. This column is not returned by 1.x providers. |
PK_TABLE_CATALOG | DBTYPE_WSTR | Catalog name in which the primary key table is defined. NULL if the provider does not support catalogs. |
PK_TABLE_SCHEMA | DBTYPE_WSTR | Unqualified schema name in which the primary key table is defined. NULL if the provider does not support schemas. |
PK_TABLE_NAME | DBTYPE_WSTR | Primary key table name. |
PK_COLUMN_NAME | DBTYPE_WSTR | Primary key column name. This column, together with the PK_COLUMN_GUID and PK_COLUMN_PROPID columns, forms the column ID. One or more of these columns will be NULL depending on which elements of the DBID structure the provider uses. |
PK_COLUMN_GUID | DBTYPE_GUID | Primary key column GUID. |
PK_COLUMN_PROPID | DBTYPE_UI4 | Primary key column property ID. |
FK_NAME | DBTYPE_WSTR | Foreign key name. NULL if the provider does not support named foreign key constraints. This column is not returned by 1.x providers. |
FK_TABLE_CATALOG | DBTYPE_WSTR | Catalog name in which the foreign key table is defined. NULL if the provider does not support catalogs. |
FK_TABLE_SCHEMA | DBTYPE_WSTR | Unqualified schema name in which the foreign key table is defined. NULL if the provider does not support schemas. |
FK_TABLE_NAME | DBTYPE_WSTR | Foreign key table name. |
FK_COLUMN_NAME | DBTYPE_WSTR | Foreign key column name. This column, together with the FK_COLUMN_GUID and FK_COLUMN_PROPID columns, forms the column ID. One or more of these columns will be NULL depending on which elements of the DBID structure the provider uses. |
FK_COLUMN_GUID | DBTYPE_GUID | Foreign key column GUID. |
FK_COLUMN_PROPID | DBTYPE_UI4 | Foreign key column property ID. |
ORDINAL | DBTYPE_UI4 | The order of the column names (and GUIDs and property IDs) in the key. For example, a table might contain several foreign key references to another table. The ordinal starts over for each reference; for example, two references to a three-column key would return 1, 2, 3, 1, 2, 3. |
UPDATE_RULE | DBTYPE_WSTR | If an <update rule> was specified, then the UPDATE_RULE value is one of the following: "CASCADE"—A <referential action> of CASCADE was specified. "SET NULL"—A <referential action> of SET NULL was specified. "SET DEFAULT"—A <referential action> of SET DEFAULT was specified. "NO ACTION"—A <referential action> of NO ACTION was specified. Providers should return NULL only if they cannot determine the UPDATE_RULE. In most cases, this implies a default of NO ACTION. |
DEFERRABILITY | DBTYPE_12 | Deferrability of the foreign key. Value is one of the following: DBPROPVAL_DF_INITIALLY_DEFERRED DBPROPVAL_DF_INITIALLY_IMMEDIATE DBPROPVAL_DF_NOT_DEFERRABLE This column is not returned by 1.x providers. |
DELETE_RULE | DBTYPE_WSTR | If a <delete rule> was specified then the DELETE_RULE value is one of the following: "CASCADE"—A <referential action> of CASCADE was specified. "SET NULL"—A <referential action> of SET NULL was specified. "SET DEFAULT"—A <referential action> of SET DEFAULT was specified. "NO ACTION"—A <referential action> of NO ACTION was specified. Providers should return NULL only if they cannot determine the DELETE_RULE. In most cases, this implies a default of NO ACTION. |
Default Sort Order: FK_TABLE_CATALOG, FK_TABLE_SCHEMA, FK_TABLE_NAME