LoginSignup
3
2

More than 5 years have passed since last update.

PostgreSQLの「COPY」で特定のデータをダンプし別のDBに投入するメモ

Posted at

ダンプ

db=# copy(select * from table_name where id > 320) to '/home/username/db_dump_20161011.dump';
COPY 20

ダンプしたデータの投入

copy句だと怒られる。

db=> copy sample_table from '/home/username/db_dump_20161011.dump';
ERROR:  must be superuser to COPY to or from a file
HINT:  Anyone can COPY to stdout or from stdin. psql's \copy command also works for anyone.

取り急ぎ\copyで実行

db=> \copy sample_table from '/home/username/db_dump_20161011.dump';
COPY 56
3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2