Copy a table from one database to another in Postgres

前端 未结 19 1252
慢半拍i
慢半拍i 2020-11-28 00:21

I am trying to copy an entire table from one database to another in Postgres. Any suggestions?

19条回答
  •  旧巷少年郎
    2020-11-28 01:05

    If you have both remote server then you can follow this:

    pg_dump -U Username -h DatabaseEndPoint -a -t TableToCopy SourceDatabase | psql -h DatabaseEndPoint -p portNumber -U Username -W TargetDatabase
    

    It will copy the mentioned table of source Database into same named table of target database, if you already have existing schema.

提交回复
热议问题