Subject Re: [firebird-support] Re: List of table constraints
Author Mark Rotteveel
eddressel wrote:
> Thank you for your response.
>
>> From RDB$RELATION_CONSTRAINTS, naturally.
>
> Don't know if it makes a difference, I am using FB 1.5, and I could not find that.

RDB$RELATION_CONSTRAINTS already existed in Interbase 6, it is also
available in Firebird 1.5

>> Have you ever read Language Reference?..
>
> yes, searched the PDF for 'constraint' and that was no help.

The table is described on page 263 of the Language Reference
(LANGREF.pdf; of Interbase 6).

> I found the following SQL provides the information I need:
>
> SELECT RDB$INDEX_NAME
> FROM RDB$INDICES
> WHERE RDB$RELATION_NAME='TABLENAME'
> AND (RDB$UNIQUE_FLAG IS NOT NULL OR RDB$FOREIGN_KEY IS NOT NULL);

This won't give all contraints. Only UNIQUE and FOREIGN KEY and you
won't be sure which UNIQUE index is the primary key, and a UNIQUE index
does not necessarily have a UNIQUE constraint.
--
Mark Rotteveel