Subject Re: [firebird-support] Find column to foreign key constraint
Author Martijn Tonies
Hi,

> I'm trying to select all column that contain a
> foreign key constraint.
>
> I know how to select all FKs and their tablenames
> using the following SQL
>
> select
> c.rdb$constraint_name,
> c.rdb$relation_name
> from
> rdb$relation_constraints c
> where
> c.rdb$constraint_type = 'FOREIGN KEY'
>
> But how can I find the column name the FK is on?
>
> I tried to join with RDB$DEPENDENCIES without success.

Have a look at RDB$REF_CONSTRAINTS, RDB$INDICES and
RDB$INDEX_SEGMENTS as well.

Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com