Copy a table from one database to another in Postgres

前端 未结 19 1254
慢半拍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:04

    Using dblink would be more convenient!

    truncate table tableA;
    
    insert into tableA
    select *
    from dblink('hostaddr=xxx.xxx.xxx.xxx dbname=mydb user=postgres',
                'select a,b from tableA')
           as t1(a text,b text);
    

提交回复
热议问题