Displaying output as CSV

For those of you using psql to work with PostgreSQL, there is more—psql can't display data in CSV format, as shown in the next listing:

test=# pset format csv
Output format is csv.
test=# SELECT id, id FROM generate_series(1, 4) AS id;
id,id
1,1
2,2
3,3
4,4

This is especially useful if you are using psql in a shell script and if you are piping data from one program to the next. If you always want to get data in CSV format, you can add the pset command to your .psqlrc file. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset