0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PostgreSQL の psql コマンドでタブ区切りで select 結果を出力

Posted at

PostgreSQL の psql コマンドでタブ区切りで select 結果を出力する方法のメモ。

オプション

  • -t: カラム名等を抑制
  • -A: 整形を抑止
  • -F $'\t': カラムの区切り文字をタブに変更

コマンド

echo "select * from test1;" | psql -t -A -F $'\t' -d test1

実行結果

id_001	name_001
id_002	name_002
id_003	name_003
id_004	name_004
id_005	name_005

オプションを指定しない場合

   id   |   name
--------+----------
 id_001 | name_001
 id_002 | name_002
 id_003 | name_003
 id_004 | name_004
 id_005 | name_005
(5 rows)
0
0
1

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?