|Subject||Re: [firebird-support] How to get the the tables and the columns of a Foreign Key?|
|Author||Walter R. Ojeda Valiente|
Thank you very much SET.
Yes, it will be useful. No exactly what I was looking for but good enough for know the names of the tables and the columns involved.
On Tue, May 30, 2017 at 3:38 AM, Svein Erling Tysvær setysvar@... [firebird-support] <firstname.lastname@example.org> wrote:Hopefully this can get you started (though since your key consists of two fields, I would expect it to return four rows, not one row with two tables and four fields):select iChild.rdb$Relation_name, isChild.rdb$field_name, iMain.rdb$relation_name, isMain.rdb$field_namefrom rdb$indices iChildjoin rdb$index_segments isChild on iChild.rdb$index_name = isChild.rdb$index_namejoin rdb$indices iMain on iChild.rdb$Foreign_key = iMain.rdb$index_namejoin rdb$index_segments isMain on iMain.rdb$index_name = isMain.rdb$index_namewhere iChild.rdb$index_name = 'FK_ADHERENTES'HTH,Set2017-05-30 7:10 GMT+02:00 'Walter R. Ojeda Valiente' sistemas2000profesional@gmail. com [firebird-support] <firebird-support@yahoogroups. com>:
Hello everybodyI had defined a Foreign Key as:ALTER TABLE ADHERENTESADD CONSTRAINT FK_ADHERENTESFOREIGN KEY (ADH_SERVID, ADH_IDECAB)REFERENCES CLIENTES(CLI_SERVID, CLI_IDENTI)ON DELETE CASCADEON UPDATE CASCADE;Of course, that work very well.However, after watching the system tables I can not find a simple way to build a SELECT what can give me the name of the tables and the columns involved. Something as:SELECT ... somethingResult:ADHERENTES, ADH_SERVID, ADH_IDECAB, CLIENTES, CLI_SERVID, CLI_IDENTICan somebody tell me how to get that result?Thank you very much in advance.Greetings.Walter.