0

I am using COPY public.source TO STDOUT; It is copying table source from database foo and sending it to psql shell.

1   1   1
2   2   2
3   0   3
4   1   4
5   2   0
6   0   1
7   1   2
8   2   3
9   0   4
10  1   0

I want to copy all records from the same table source of database foo to table dest in database bar. Any idea how can I do it with query like COPY public.source TO <missing solution to copy data into bar.public.dest>;

2
  • 1
    I think it's better to do this in the shell and not with sql commands, see stackoverflow.com/questions/3195125/…. Commented May 8, 2020 at 13:07
  • I am also to remove elixir tag since the question has nothing to do with elixir. Commented May 8, 2020 at 13:19

1 Answer 1

1

Here is answering the particular question about using COPY.

According to the documentation on PostgresSQL COPY,

COPY — copy data between a file and a table

which roughly means you are to do this in two steps: copy the existing data from source DB to file/stdin and then copy from file/stdin to destination DB.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.