Developer's Lab

By Diogo Pinto - DiØ

Getting Column Name Bound With Unique Constraint

Here you can see, how we can get the column name bound with specific unique constraint name…For example:

select k.COLUMN_NAME
    from information_schema.KEY_COLUMN_USAGE k
    join information_schema.TABLE_CONSTRAINTS tc on k.TABLE_SCHEMA = tc.TABLE_SCHEMA 
    and k.TABLE_SCHEMA = tc.TABLE_SCHEMA
    and k.CONSTRAINT_NAME = tc.CONSTRAINT_NAME
    where k.table_name = 'table_name'
    and constraint_type = 'UNIQUE';

Comments