数据库 Postgres 数据库复制

ericwu · August 12, 2013 · 4769 hits

前几天开发的时候想把 development 的数据库里面的数据导到 production 中,其中有 yaml_db 可以做,但是这样会占用很多内存,然后发现在 digital ocean 上面会被 server kill 掉,然后查了好久在 stackoverflow 上看到一个回答:http://stackoverflow.com/questions/876522/creating-a-copy-of-a-database-in-postgres

Postgres allows the use of any existing database on the server as a template when creating a new database.

Postgres 在新建数据库的时候允许使用在服务器上已经存在的数据库作为模板。

然后你就可以这样做

CREATE DATABASE newdb WITH TEMPLATE originaldb OWNER dbuser;

然后这瞬间就创建好了一个新的数据库。

No Reply at the moment.
You need to Sign in before reply, if you don't have an account, please Sign up first.