To select from another database I try to use dblink or fdw extension of Postgres, like this:
CREATE EXTENSION dblink;
SELECT * FROM
dblink ('dbname = bd_name port = 5432 host = 10.6.6.6 user = username password = password',
'SELECT id, code FROM sch_schema.table')
AS new_table(id INTEGER, code character varying);
This works fine when I specify which columns I want to select.
My problem is: How can I select all the columns?
I tried this:
SELECT * FROM
dblink ('dbname = bd_name port = 5432 host = 10.6.6.6 user = username password = password',
'SELECT * FROM sch_schema.table');
But this does not work. How can I solve this problem?