To find the tables that reference a table, ask the database’s catalogue for foreign keys whose referenced table is yours. Every engine records that, but each stores it differently, and the answer it gives back has two traps: some engines list one foreign key several times, and most engines can list keys that enforce nothing. A third gap is a reference nobody declared, which no catalogue can show.

Everything below was run in throwaway containers on PostgreSQL 18.3, MySQL 8.4.11 and SQL Server 2022 (CU26), and with the sqlite3 3.54.0 shell, against a customers table with orders, addresses and a payments table in a second schema pointing at it.

How to find which tables reference a table

Query the foreign keys whose target is your table: one catalogue lookup per engine, with SQLite as the exception that has to scan every table.

DatabaseWhere incoming keys are recordedThe ON DELETE actionQuick look
PostgreSQLpg_constraint.confrelidconfdeltype, or pg_get_constraintdefpsql \d customers, under Referenced by
MySQLinformation_schema.KEY_COLUMN_USAGE.REFERENCED_TABLE_NAMEREFERENTIAL_CONSTRAINTS.DELETE_RULEnone: SHOW CREATE TABLE shows only outgoing keys
SQL Serversys.foreign_keys.referenced_object_iddelete_referential_action_descEXEC sp_fkeys @pktable_name = 'customers', with the rule as a number (0 is CASCADE) and no disabled flag
SQLitenowhere: each table lists only its own keyspragma_foreign_key_list(...).on_deletenone

The queries, one per engine:

-- PostgreSQL
SELECT conrelid::regclass AS referencing_table, conname,
       pg_get_constraintdef(oid) AS definition, convalidated
FROM pg_constraint
WHERE contype = 'f' AND confrelid = 'customers'::regclass AND conparentid = 0
ORDER BY 1;

-- MySQL
SELECT k.TABLE_SCHEMA, k.TABLE_NAME, k.CONSTRAINT_NAME, k.COLUMN_NAME, r.DELETE_RULE
FROM information_schema.KEY_COLUMN_USAGE k
JOIN information_schema.REFERENTIAL_CONSTRAINTS r
  ON r.CONSTRAINT_SCHEMA = k.CONSTRAINT_SCHEMA AND r.CONSTRAINT_NAME = k.CONSTRAINT_NAME
WHERE k.REFERENCED_TABLE_SCHEMA = 'shop' AND k.REFERENCED_TABLE_NAME = 'customers'
ORDER BY k.TABLE_SCHEMA, k.TABLE_NAME, k.ORDINAL_POSITION;

-- SQL Server
SELECT OBJECT_SCHEMA_NAME(parent_object_id) AS referencing_schema,
       OBJECT_NAME(parent_object_id) AS referencing_table, name,
       delete_referential_action_desc, is_disabled, is_not_trusted
FROM sys.foreign_keys
WHERE referenced_object_id = OBJECT_ID('dbo.customers');

All three found the key from payments in the other schema, because they filter on the referenced table, not on the referencing one. On MySQL that is a second database, billing.payments, listed with DELETE_RULE NO ACTION, the rule MySQL records when none is written. A column declared with only an inline customer_id BIGINT REFERENCES customers (id) did not appear at all, because MySQL 8.4 accepts that clause and creates no key, as the post on checking migrations in CI measured.

Why does the same foreign key appear three times in PostgreSQL?

Because PostgreSQL copies a foreign key onto every partition of a partitioned table, and the copies are rows in pg_constraint too.

With orders partitioned by year into orders_2025 and orders_2026, the same lookup without conparentid = 0, selecting confdeltype for the action, returned five rows for customers where there are three keys:

 referencing      | conname                    | confdeltype
------------------+----------------------------+-------------
 orders           | orders_customer_id_fkey    | r
 orders_2025      | orders_customer_id_fkey    | r
 orders_2026      | orders_customer_id_fkey    | r
 addresses        | addresses_customer_id_fkey | c
 billing.payments | payments_customer_id_fkey  | a

A key into a partitioned table is copied too, the other way round. The key from invoices into orders is stored three times, once pointing at orders and once at each partition, so the incoming list for orders shows it once, but invoices shows three outgoing keys and each partition shows one incoming key. Each copy names its original in conparentid, so keeping only conparentid = 0 returns one row per key in every direction:

orders_customer_id_fkey  (orders -> customers)
├── copy on orders_2025
└── copy on orders_2026
invoices_order_id_order_created_at_fkey  (invoices -> orders)
├── ..._fkey_1, pointing at orders_2025
└── ..._fkey_2, pointing at orders_2026

psql’s \d customers already hides them: its Referenced by section listed addresses, orders and billing.payments once each, and marked the unvalidated key NOT VALID. The 'customers'::regclass cast resolves the name through search_path, so qualify it ('public.customers'::regclass) when another schema has a table of the same name.

SQLite: why is there no reverse lookup?

SQLite stores each foreign key only in the CREATE TABLE of the table that declares it, so finding the incoming ones means reading every table’s list.

SELECT m.name AS referencing_table, p."from" AS column_name,
       p."to" AS referenced_column, p.on_delete
FROM sqlite_schema m
JOIN pragma_foreign_key_list(m.name) p
WHERE m.type = 'table' AND p."table" = 'customers' COLLATE NOCASE
ORDER BY m.name;

The COLLATE NOCASE matters. The referenced name is stored as written, and addresses had been declared with REFERENCES Customers (id); a plain = 'customers' returned only orders. A key pointing at a table that does not exist, such as a typo REFERENCES customer (id), is accepted by CREATE TABLE and simply never matches. The SQLite foreign key documentation explains the other catch: enforcement is off unless each connection runs PRAGMA foreign_keys = ON, and with it off an orders row pointing at customer 42, who did not exist, went in without a complaint.

Which listed foreign keys actually enforce anything?

Not all of them: PostgreSQL lists unvalidated keys, SQL Server lists disabled and untrusted keys, and MySQL and SQLite keep no record of rows written with checks off, so read the state columns before trusting the list.

DatabaseState to checkWhat it meansMeasured
PostgreSQLconvalidated = false (added NOT VALID)New rows are checked; existing rows never wereAn address pointing at customer 99 stayed after the key was added
PostgreSQL 18conenforced = false (NOT ENFORCED)Nothing is checked
SQL Serveris_disabled = 1 (NOCHECK CONSTRAINT)No check and no actionA disabled CASCADE key left the address behind when its customer was deleted
SQL Serveris_not_trusted = 1 (added WITH NOCHECK)Checked from now on; rows already there never werepayments kept a row pointing at customer 99
MySQLforeign_key_checks = 0 on the session, with no flag in the catalogueRows written while it was off were never checkedAn orphan address went in while TABLE_CONSTRAINTS.ENFORCED still said YES
SQLitePRAGMA foreign_keys on the connectionOff by default, per connectionAn orphan order inserted with it off

The SQL Server case is the one that misleads most. sys.foreign_keys reported the disabled key on addresses with delete_referential_action_desc CASCADE (and is_not_trusted = 1, as every disabled key has). Deleting customer 2 succeeded and left address 6 holding customer_id = 2, a customer that no longer existed. Anyone reading the catalogue to answer “what does deleting a customer take with it” would have been told the addresses go too.

There is also what no catalogue records: a reference nobody declared. A Rails or Django app that never added the constraint still has orders.customer_id meaning a customer, and the queries above return nothing for it. Finding those is a different job, covered in whether to use foreign key constraints, which also shows how to count the orphans before declaring one.

How does Schemity show the keys pointing at a table?

Schemity lists the foreign keys in the diagram that point at a table in that table’s Keys tab, once each, with their columns and their ON DELETE and ON UPDATE actions.

Schemity is database design software that reads your live database, shows the impact of every schema change before it runs, and keeps the diagram as a file in Git. Open a table and the read-only Keys tab of its drawer shows up to three lists: the primary key, the foreign keys the table declares, and Referenced by, the keys in other tables that point at it. A key the database does not enforce is tagged NOT ENFORCED, and a relation you drew yourself for a reference nobody declared is tagged virtual (see virtual relations). Selecting a table on the canvas draws every relation touching it at double weight, which is the same answer as a picture. That is the point of reading a live database to understand your schema: the list comes from the catalogue, not from someone’s memory of it.

Schemity's Keys tab for the customers table on PostgreSQL 18.3: the primary key customers_pkey on id, and under Referenced by two foreign keys, addresses_customer_id_fkey on addresses(customer_id) with CASCADE on delete and NO ACTION on update, and orders_customer_id_fkey on orders(customer_id) with RESTRICT and NO ACTION, each listed once although orders is partitioned; the footer counts 4 entities and 3 relations.

Checking this post’s partitioned orders table found a bug. Schemity read only ordinary tables, so the partitioned parent was missing from the diagram, each partition showed up as a table of its own, and every key was drawn once per partition, the same repetition as the naive query above. In the next release a partitioned table is read as one table: its columns, keys, checks and indexes once, its row count and size summed across its partitions, and the views that read it listed as its dependents for impact analysis.

Schemity's canvas on PostgreSQL 18.3 with the customers table selected: the partitioned orders table appears once, with created_at, id and customer_id and no orders_2025 or orders_2026, next to invoices and addresses; the relations from customers to orders and to addresses are drawn at double weight, and the footer counts 4 entities and 3 relations.

What the Keys tab does not show matters as much. It lists keys between tables of the diagram’s schema; a key from another schema, like billing.payments, is read as a dependent for impact analysis but does not appear under Referenced by. A PostgreSQL key added NOT VALID and a SQL Server key that is disabled or untrusted are shown as ordinary keys, so the disabled CASCADE above would read as a cascade. Schemity does not yet know a table’s partition key, so it does not warn that PostgreSQL refuses a UNIQUE constraint on a partitioned table without it. And a reference nobody declared shows only if you draw it. Impact analysis reads the database, not your application, so an empty Referenced by list is not proof that nothing reads the table.

Before you rely on the list

Run the catalogue query, then read the state of each key it returns, then ask what it cannot contain.

On PostgreSQL filter conparentid = 0 and look at convalidated; on SQL Server look at is_disabled and is_not_trusted; on SQLite compare names without case and remember enforcement is per connection; on MySQL filter on the referenced schema so keys from other databases come back too. Then look for the references nobody declared, because the catalogue only knows what was written down. For what happens when one of those keys fires, see ON DELETE RESTRICT vs NO ACTION and what DROP TABLE CASCADE drops in PostgreSQL.

Frequently asked questions

How do I find all foreign keys that reference a table in PostgreSQL?

Query pg_constraint with contype = 'f' and confrelid = 'your_table'::regclass, and add conparentid = 0. Without that filter a foreign key from a partitioned table is listed once for the parent and again for every partition. psql's \d your_table shows the same list under Referenced by, already without the copies.

Does a disabled foreign key in SQL Server still cascade deletes?

No. A key turned off with NOCHECK CONSTRAINT neither checks new rows nor runs its ON DELETE CASCADE. In a test on SQL Server 2022, deleting a customer left its address row behind, pointing at an id that no longer existed, while sys.foreign_keys still listed the key with CASCADE and is_disabled = 1.

Why does SQLite not list a foreign key that references my table?

SQLite keeps no reverse index of foreign keys, so you have to read pragma_foreign_key_list for every table and filter on the referenced table name. That name is stored as written in each CREATE TABLE, so compare it with COLLATE NOCASE: a key written as REFERENCES Customers is missed by a plain equality on customers.