Subject Re: [firebird-support] Dropping an unnamed constraint
Author Tetram Corp
Sorry,

select rc.rdb$constraint_name
from rdb$relation_constraints rc
inner join rdb$index_segments indexes
on rc.rdb$index_name = indexes.rdb$index_name
where rc.rdb$constraint_type = 'UNIQUE'
and rc.rdb$relation_name = 'YOURTABLE'
and indexes.rdb$field_name = 'NUMBER'

will be better

(be aware that only primary and foreign keys can be found in the same
way. Not "not null" constraints)

Thierry

Tetram Corp a écrit :
> hi,
>
> something like:
>
> select rc.rdb$constraint_name
> from rdb$relation_constraints rc
> inner join rdb$index_segments is
> on rc.rdb$index_name = is.rdb$index_name
> where rc.rdb$contraint_type = 'UNIQUE'
> and rc.rdb$relation_name = 'YOURTABLE'
> and is.rdb$field_name = 'NUMBER'
>
> should retrun what you need
>
> be careful, is this field appears in more than one unique contraint of
> your table, you will have more than one result
>
> Regards,
> Thierry
>
> Tobias Grimm a écrit :
>
>> Hi!
>>
>> When creating e.g. a UNIQUE constraint with:
>>
>> ALTER TABLE PRODUCT ADD UNIQUE (NUMBER);
>>
>> ...without specifying a constraint name, the contstraint gets a "random"
>> name like "INTEG_36".
>>
>> How can I query this automatically created constraint name (given the
>> table name, column name and constraint type), to be able to drop it?
>>
>> bye,
>> Tobias
>>
>>
>>