postgresql: is possible to rename a table from db1 to db2?

88 Views Asked by At

On mysql supposing I want to rename table buildings from db1 to db2

rename table db1.buildings to db2.buildings;

On postgres I known how to rename a table inside the same db

alter table buildings rename to newbuildings;

Is possible to rename from db1 to db2 on postgres?

2

There are 2 best solutions below

0
elbarna On BEST ANSWER

I have found another solution

pg_dump db1 -t buildings| psql db2
2
nbk On

Use ALTER TABLE SET SCHEMA

ALTER TABLE db1.buildings SET SCHEMA db2;