Finding foreign tables in Postgres

Matt

Administrator
Staff member
Oct 1, 2017
9
0
1
#1
Metadata about Foreign tables in PostgreSQL is not stored in the same system catalog as regular tables. The system catalog is pg_foreign_table.

Code:
+-----------+--------+-----------+----------+---------+
|  Column   |  Type  | Collation | Nullable | Default |
+-----------+--------+-----------+----------+---------+
| ftrelid   | oid    |           | not null |         |
| ftserver  | oid    |           | not null |         |
| ftoptions | text[] |           |          |         |
+-----------+--------+-----------+----------+---------+
To find the actual foreign table name you can run a query like this:

SQL:
select relname from pg_foreign_table ft
join pg_class c on c.oid = ft.ftrelid;