Segfault-Inc / Multicorn

Data Access Library
https://multicorn.org/
PostgreSQL License
700 stars 145 forks source link

Convert foreign table to real? #113

Closed johnmudd closed 9 years ago

johnmudd commented 9 years ago

Any suggestions to convert a foreign table to real table?

So far I can use pg_dump to get the CREATE TABLE statement. After editing the output.

And I can use the following to dump the data. Is there a better approach?

COPY (SELECT * from my_fdw_table) TO STDOUT WITH CSV HEADER;

rotten commented 9 years ago

Wouldn't 'select into' work? -- http://www.postgresql.org/docs/9.4/static/sql-selectinto.html

johnmudd commented 9 years ago

SELECT INTO executes and creates the new table but the new table has no columns or rows.

rdunklau commented 9 years ago

What do you mean ? Could you post an example ?

Both forms work for me:

select * into table new_local_table from foreign_table; create table new_local_table AS (select * from foreign_table);

johnmudd commented 9 years ago

You are correct, thanks! I tried "SELECT INTO" instead of "SELECT * INTO".