Outputting from Postgres to CSV

Ian P. Christian's personal blog

Quicksearch

Recent Entries

Calendar

Back July '09
Mon Tue Wed Thu Fri Sat Sun
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Blog Administration


Trackbacks

No Trackbacks

Comments
Display comments as (Linear | Threaded)

After much pain with line endings:

COPY (SELECT foo,bar FROM whatever) TO '/tmp/dump.csv' WITH CSV HEADER
#1 Ben on 2008-06-05 11:57 (Reply)
I also can never remember how to do this, and I always google it, and end up here. So, thank you for keeping this handy!!!
#2 Dave (Homepage) on 2009-02-27 22:42 (Reply)

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
 
Submitted comments will be subject to moderation before being displayed.