Query below lists all tables refrenced with foregin key by specific table.
select table_schema || '.' || table_name as fk_table, '>-' as rel, reference_table_schema || '.' || reference_table_name as primary_table from v_catalog.foreign_keys where table_name = 'store_orders_fact' -- and table_schema = 'store' order by primary_table;
- fk_table - foreign table name with schema name - the table you provided as a parameter
- rel - relationship symbol implicating FK and direction
- primary_table_name - primary (rerefenced) tables names with schema name - the tables you are looking for
- One row represents one referenced table
- Scope of rows: all tables referenced by table with provided name (and optionally schema)
- Ordered by referenced table schema and name
- There can be more tables with the same name. If that's the case, uncomment where clause and provide schema name
All tables referenced with FK by store.store_orders_fact table in VMart database.