Subject | List of all foreign keys for all tables in database |
---|---|
Author | Thomas Vedel Consult |
Post date | 2004-03-20T00:01:32Z |
Hi all
I am using FB 1.5
I need a list showing all foreign keys in the database including
referenced tables. I know this can be produced by a join of system
tables, but I can not figure out, exactly how it should be done.
I have studied the description of the system tables carefully in both
the IB6 documentation and in the Firebird Reference guide, but I am a
bit stuck. I really hope someone can help me!
I have created the following select statement showing all constraints -
but I would like the referenced tables and fields added to the view
--------------------------------------------------------
SELECT
RDB$INDICES.RDB$RELATION_NAME,
RDB$INDEX_SEGMENTS.RDB$FIELD_NAME,
RDB$RELATION_CONSTRAINTS.RDB$CONSTRAINT_TYPE,
RDB$INDICES.RDB$INDEX_NAME
FROM RDB$INDEX_SEGMENTS
LEFT OUTER JOIN RDB$RELATION_CONSTRAINTS ON
(RDB$RELATION_CONSTRAINTS.RDB$INDEX_NAME =
RDB$INDEX_SEGMENTS.RDB$INDEX_NAME)
INNER JOIN RDB$INDICES ON (RDB$INDEX_SEGMENTS.RDB$INDEX_NAME =
RDB$INDICES.RDB$INDEX_NAME)
WHERE
(
(RDB$INDICES.RDB$RELATION_NAME NOT LIKE 'RDB$%')
);
--------------------------------------------------------
Thanks in advance for any hints
Thomas Vedel
[Non-text portions of this message have been removed]
I am using FB 1.5
I need a list showing all foreign keys in the database including
referenced tables. I know this can be produced by a join of system
tables, but I can not figure out, exactly how it should be done.
I have studied the description of the system tables carefully in both
the IB6 documentation and in the Firebird Reference guide, but I am a
bit stuck. I really hope someone can help me!
I have created the following select statement showing all constraints -
but I would like the referenced tables and fields added to the view
--------------------------------------------------------
SELECT
RDB$INDICES.RDB$RELATION_NAME,
RDB$INDEX_SEGMENTS.RDB$FIELD_NAME,
RDB$RELATION_CONSTRAINTS.RDB$CONSTRAINT_TYPE,
RDB$INDICES.RDB$INDEX_NAME
FROM RDB$INDEX_SEGMENTS
LEFT OUTER JOIN RDB$RELATION_CONSTRAINTS ON
(RDB$RELATION_CONSTRAINTS.RDB$INDEX_NAME =
RDB$INDEX_SEGMENTS.RDB$INDEX_NAME)
INNER JOIN RDB$INDICES ON (RDB$INDEX_SEGMENTS.RDB$INDEX_NAME =
RDB$INDICES.RDB$INDEX_NAME)
WHERE
(
(RDB$INDICES.RDB$RELATION_NAME NOT LIKE 'RDB$%')
);
--------------------------------------------------------
Thanks in advance for any hints
Thomas Vedel
[Non-text portions of this message have been removed]