Hi, On 22 November 2011 06:10, Joost Kraaijeveld <J.Kraaijeveld@xxxxxxxxxx> wrote: > Is it possible, and if so how, to export a single column of a table into > a separate file per row? I have a table with ~21000 rows that have a > column "body1" containing ASCII text and I want to have 21000 separate > ASCII files, each containing that column "body1". The name of the file > does not matter, although it would be nice if they had the extension > "txt". Something like this could do the job: for i in `psql -a -t -c 'select id from T'`; do psql -a -t -c "select body1 from T where id = $i" -o $i.txt; done; where 'T' is your table and 'id' is primary column in that table. I've omitted connection options (-h -U ...) from psql commands. -- Ondrej Ivanic (ondrej.ivanic@xxxxxxxxx) -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general