Re: "psql -At -F" export column from table to .csv

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Nina <dingjia(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: "psql -At -F" export column from table to .csv
Date: 2006-02-11 19:37:51
Message-ID: 20060211193751.GK4474@ns.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

* Nina (dingjia(at)gmail(dot)com) wrote:
> I think you maybe familiar with this command:
> psql -At -F "," -c "select ..." > query.csv
>
> My question is:
> is it possible to export several different columns from different
> tables into the same .csv file; something like: psql -At -F "," -c
> "select ..." "select ..." "select ..." "select ..." > query.csv
>
> Then, how to write the command in the correct way?

for table in a b c; do
psql -At -F "," -c "select ... from $table" >> query.csv
done

Enjoy,

Stephen

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Johan Vromans 2006-02-11 20:26:57 Re: Last modification time
Previous Message Doug McNaught 2006-02-11 19:00:08 Re: Last modification time