elbarna
elbarna

Reputation: 727

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

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?

Upvotes: 0

Views: 93

Answers (2)

elbarna
elbarna

Reputation: 727

I have found another solution

pg_dump db1 -t buildings| psql db2

Upvotes: 0

nbk
nbk

Reputation: 49373

Use ALTER TABLE SET SCHEMA

ALTER TABLE db1.buildings SET SCHEMA db2;

Upvotes: 3

Related Questions