table_constraints

The view information_schema.table_constraints contains all table constraints defined on tables in the database. It includes PRIMARY KEY, UNIQUE and FOREIGN KEY constraints.

SELECT * FROM information_schema.table_constraints;
SELECT constraint_schema, constraint_name, table_name, constraint_type
 FROM information_schema.table_constraints WHERE NOT is_system;

information_schema.table_constraints

column nametyperemarks
constraint_catalogVARCHARAlways NULL
constraint_schemaVARCHAR
constraint_nameVARCHAR
table_catalogVARCHARAlways NULL
table_schemaVARCHAR
table_nameVARCHAR
constraint_typeVARCHARPRIMARY KEY or UNIQUE or FOREIGN KEY
is_deferrableVARCHARNO or YES
initially_deferredVARCHARNO or YES
enforcedVARCHARNO or YES
schema_idINTEGERreference to sys.schemas.id
table_idINTEGERreference to sys.tables.id
key_idINTEGERreference to sys.keys.id
key_typeINTEGERreference to sys.key_types.key_type_id
is_systemBOOLEANtrue when it is a constraint for a system table, else false

Note: The last 5 columns (schema_id, table_id, key_id, key_type and is_system) are extensions to the view as defined by ISO standard. They provide useful information and simplify filtering and joins with system tables/views in sys schema when needed.