Search code examples
postgresqlpostgres-fdw

Create a foreign table pointing to a view in Postgres


Is it possible to create a foreign table, using Postgres Foreign Data Wrapper, that points to a view instead of a table?


Solution

  • Yes, it is possible!

    The following query worked perfectly:

    CREATE FOREIGN TABLE facts(name character varying(255))
    SERVER my_server 
    OPTIONS (table_name 'facts');
    

    Where facts is a view in my_server instead of a table.