'In Postgres, can you create local table based on remote tabls schema using dblink?
Currently, I am using the following command to create a table schema, based on another table schema.
CREATE TABLE schema_1.MynewTable (LIKE schema_2.TheoldTable INCLUDING ALL);
This works great. Now, however the "source" table is in a different server/db. I have setup dblink extension, but I can't find an easy way to use it to create a local table based on remote table schema. What I'd like to be able to do is something like.
CREATE TABLE schema_1.MynewTable (LIKE remoteServer.schema_2.TheoldTable INCLUDING ALL);
where I would define the connection details for remoteServer
Is this possible? Or Do I need to manually extract the create script and use that to create the new table...which is a bit of a pain.
I'm currently on Postgres 11
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
