REFERENTIAL_CONSTRAINTS (Transact-SQL)

REFERENTIAL_CONSTRAINTS (Transact-SQL)

 

THIS TOPIC APPLIES TO:yesSQL Server (starting with 2008)yesAzure SQL DatabasenoAzure SQL Data Warehouse noParallel Data Warehouse

Returns one row for each FOREIGN KEY constraint in the current database. This information schema view returns information about the objects to which the current user has permissions.

To retrieve information from these views, specify the fully qualified name of INFORMATION_SCHEMA.view_name.

Column nameData typeDescription
CONSTRAINT_CATALOGnvarchar(128)Constraint qualifier.
CONSTRAINT_SCHEMAnvarchar(128)Name of schema that contains the constraint.

 ** Important ** Do not use INFORMATION_SCHEMA views to determine the schema of an object. The only reliable way to find the schema of a object is to query the sys.objects catalog view.
CONSTRAINT_NAMEsysnameConstraint name.
UNIQUE_CONSTRAINT_CATALOGnvarchar(128)UNIQUE constraint qualifier.
UNIQUE_CONSTRAINT_SCHEMAnvarchar(128)Name of schema that contains the UNIQUE constraint.

 ** Important ** Do not use INFORMATION_SCHEMA views to determine the schema of an object. The only reliable way to find the schema of a object is to query the sys.objects catalog view.
UNIQUE_CONSTRAINT_NAMEsysnameUNIQUE constraint.
MATCH_OPTIONvarchar(7)Referential constraint-matching conditions. Always returns SIMPLE. This means that no match is defined. The condition is considered a match when one of the following is true:

At least one value in the foreign key column is NULL.

All values in the foreign key column are not NULL, and there is a row in the primary key table that has the same key.
UPDATE_RULEvarchar(11)Action taken when a Transact-SQL statement violates the referential integrity that is defined by this constraint. Returns one of the following:
NO ACTION
CASCADE
SET NULL
SET DEFAULT

If NO ACTION is specified on ON UPDATE for this constraint, the update of the primary key that is referenced in the constraint will not be propagated to the foreign key. If such an update of a primary key will cause a referential integrity violation because at least one foreign key contains the same value, SQL Server will not make any change to the parent and referring tables. SQL Server also will raise an error.

If CASCADE is specified on ON UPDATE for this constraint, any change to the primary key value is automatically propagated to the foreign key value.
DELETE_RULEvarchar(11)Action taken when a Transact-SQL statement violates referential integrity defined by this constraint. Returns one of the following:
NO ACTION
CASCADE
SET NULL
SET DEFAULT

If NO ACTION is specified on ON DELETE for this constraint, the delete on the primary key that is referenced in the constraint will not be propagated to the foreign key. If such a delete of a primary key will cause a referential integrity violation because at least one foreign key contains the same value, SQL Server will not make any change to the parent and referring tables. SQL Server also will raise an error.

If CASCADE is specified on ON DELETE on this constraint, any change to the primary key value is automatically propagated to the foreign key value.

System Views (Transact-SQL)
Information Schema Views (Transact-SQL)
sys.indexes (Transact-SQL)
sys.objects (Transact-SQL)
sys.foreign_keys (Transact-SQL)

Community Additions

ADD
Show:
© 2016 Microsoft