0

I'm looking way to simplify CREATE FOREIGN command, so do need to specify all columns and types.

What I'm doing now (using file_fdw server):

CREATE FOREIGN TABLE temp_table_csv 
(id integer, name text)
SERVER csv_log_server
OPTIONS ( filename 'path_to_file.csv', format 'csv');

What I would like to do:

CREATE FOREIGN TABLE temp_table_csv 
(like example_table)
SERVER csv_log_server
OPTIONS ( filename 'path_to_file.csv', format 'csv');

Using LIKE or similar command so Postgres can read structure out of there But it says "like is not supported"

Maciej
  • 10,423
  • 17
  • 64
  • 97
  • 3
    I have not used it, but `import foreign schema` limited to a single table seems to be what you want: https://www.postgresql.org/docs/current/sql-importforeignschema.html –  May 13 '21 at 12:45
  • Thanks @a_horse_with_no_name - but this seems doesnt work with file_fdw extension - Ive got this: "file_fdw" does not support IMPORT FOREIGN SCHEMA – Maciej May 14 '21 at 06:24

0 Answers0