I need to display the name of all tables that depend on each other. Such tables 200 + dependent. For example, table X has FK from Y and Y has FK from Z. That is, search by FK. Can I implement FK search from the list of tables, as well as from the found tables?
Here is a query that searches for names for a single table (M_KONTRAH_GL):
SELECT master_relation_constraints.rdb$relation_name AS reference_table FROM rdb$relation_constraints detail_relation_constraints JOIN rdb$index_segments detail_index_segments ON detail_relation_constraints.rdb$index_name = detail_index_segments.rdb$index_name JOIN rdb$ref_constraints ON detail_relation_constraints.rdb$constraint_name = rdb$ref_constraints.rdb$constraint_name JOIN rdb$relation_constraints master_relation_constraints ON rdb$ref_constraints.rdb$const_name_uq = master_relation_constraints.rdb$constraint_name WHERE detail_relation_constraints.rdb$constraint_type = 'FOREIGN KEY' AND detail_relation_constraints.rdb$relation_name = 'M_KONTRAH_GL'
AND detail_relation_constraints.rdb$relation_name = 'M_KONTRAH_GL'and get all the tables - Sergey