Skip to content

Instantly share code, notes, and snippets.

@kkeeth
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save kkeeth/98190d82f0717f46ba96 to your computer and use it in GitHub Desktop.

Select an option

Save kkeeth/98190d82f0717f46ba96 to your computer and use it in GitHub Desktop.
よく使うPostgreSQLコマンド集

ちょくちょく使うPostgreSQLのコマンドをメモ。

○特定のテーブルのみバックアップ

pg_dump -t テーブル名  データベース名 --username=ユーザ名> テーブル名.sql;

○特定のテーブルのリストア

psql データベース名;  //データベースにアクセス
DROP TABLE テーブル名;  //特定のテーブルの削除
pg_restore --username=postgres -t テーブル名 データベース名 -Fc バックアップファイル名; //リストア

○バックアップファイルのリストア

psql --username=ユーザ名 データベース名 < バックアップファイル名;

 
またなにかあれば、随時更新。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment