Einzelnen Beitrag anzeigen

Benutzerbild von dataspider
dataspider

Registriert seit: 9. Nov 2003
Ort: 04539 Groitzsch
1.351 Beiträge
 
Delphi 11 Alexandria
 
#2

AW: Ermitteln von foreign keys per SQL Abfrage auf Systemtabellen

  Alt 26. Sep 2012, 09:28
Hi,

dieses Statement liefert die Tabellen mit Feldnamen:

Code:
select
    A.RDB$RELATION_NAME -- Tabellenname
  , E.RDB$FIELD_NAME as OnField -- FK
    from RDB$REF_CONSTRAINTS B, RDB$RELATION_CONSTRAINTS A, RDB$RELATION_CONSTRAINTS C,
         RDB$INDEX_SEGMENTS D, RDB$INDEX_SEGMENTS E
    where (A.RDB$CONSTRAINT_TYPE = 'FOREIGN KEY') and
          (A.RDB$CONSTRAINT_NAME = B.RDB$CONSTRAINT_NAME) and
          (B.RDB$CONST_NAME_UQ=C.RDB$CONSTRAINT_NAME) and
          (C.RDB$INDEX_NAME=D.RDB$INDEX_NAME) and
          (A.RDB$INDEX_NAME=E.RDB$INDEX_NAME) and
          (C.RDB$RELATION_NAME = :table_name) and
          (B.RDB$DELETE_RULE = 'CASCADE')
Frank
Frank Reim
  Mit Zitat antworten Zitat