0

I create a foreign server in postgresql. Before adding foreign table, I want to get list of tables in this foreign server.

Is there any way I can do this?

This sql query show the created foreign tables:

select * from information_schema.foreign_tables

But I want to know table names and structure before create it!

2 Answers 2

0

There is no way to do that. You have to connect to the remote data source directly.

0

You can use dblink to do that. It is pretty unpleasant as you have to list all the column names and types.

You can put the name of the foreign server as the first argument to dblink:

create extension dblink;
select * from dblink('the_foreign_server','select * from pg_tables') foo(sc name, tb name, ow name, ts name, ind bool, rul bool, tr bool, rls bool);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.