Ant*_*ony 4 postgresql pg-restore
我正在倾倒一个像这样的大型 Postgres 表:
pg_dump -h myserver -U mt_user --table=mytable -Fc -Z 9 --file mytable.dump mydb
Run Code Online (Sandbox Code Playgroud)
以上创建了一个mytable.dump文件。我现在想将此转储恢复到名为mytable_restored.
我怎样才能使用pg_restore命令来做到这一点?
没有pg_restore重命名表的选项。
我会这样做:
-- create a table that is defined like the original
CREATE TABLE mytable_restored (LIKE mytable INCLUDING ALL);
-- copy the table contents
COPY mytable TO '/tmp/mytable.dmp';
COPY mytable_restored FROM '/tmp/mytable.dmp';
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2886 次 |
| 最近记录: |