3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ローカル環境のPostgresのDB内のデータをcsvで取得する

Posted at

ローカル環境のPostgresデータベース内のデータをcsvで取得したときのメモです。

$ psql [データベース名] -c "select * from [取得したいテーブル名];" -A -F, | sed '$d' > [ファイル名.csv]

例:

$ psql combinator_development -c "select * from projects;" -A -F, | sed '$d' > projects.csv

確認するとprojects.csvがディレクトリに出来ていることが分かります。

$ ls

3
4
2

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
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?