Blog Pages

Get Constraints details include columns

select t.TABLE_SCHEMA, t.TABLE_NAME,
       t.CONSTRAINT_SCHEMA, t.CONSTRAINT_NAME, t.CONSTRAINT_TYPE,
       c.COLUMN_NAME
from information_schema.table_constraints t
join information_schema.constraint_column_usage c 
         on t.Constraint_Name = c.Constraint_Name
--where t.CONSTRAINT_NAME = 'UC_Something'
--where t.CONSTRAINT_TYPE = 'Unique'
--where t.TABLE_NAME = 'TableName'
...

No comments:

Post a Comment