LoginSignup
52
56

More than 5 years have passed since last update.

PostgreSQLのpg_dumpコマンドで特定のテーブルのバックアップ(ダンプ)を行う

Last updated at Posted at 2014-12-09

postgresに付属するpg_dumpツールを利用したテーブルデータのバックアップ(ダンプ)方法についてご紹介します。postgresのバージョンは8.3.7です。

データベース所有者に変更
su - [データベース所有者]
ダンプ先のフォルダに移動
cd /tmp
db_nameデータベースのtable_nameテーブルのすべてデータ(スキーマ&データ)をダンプ
pg_dump -t table_name db_name > table_name.sql
スキーマのみをダンプ
pg_dump -s -t table_name2 db_name > table_name2.sql

参考
PostgreSQL 8.3.7文書 pg_dump
http://www.postgresql.jp/document/8.3/html/app-pgdump.html
PostgreSQLのバックアップ&リストア手法その1
http://www.atmarkit.co.jp/ait/articles/0810/24/news135_2.html

以上

52
56
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
52
56