
Linux シェルから psql コマンドを実行します。結果の出力は次の表のようになります。
Name Age
-----------------
John 24
しかし、私は次のようにカンマ付きの結果を取得したいと思います。
Name,Age
John,24
シェルからの出力形式を変更するにはどうすればよいですか? Centos 5.5 と postgresql 8.4 を使用しています。
答え1
=> \a
Output format is unaligned.
=> \f ,
Field separator is ",".
=> select 'John' "Name", 24 "Age";
Name,Age
John,24