Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to export table data to file

Tags:

postgresql

I would like to export a single Postgres table's data into a .csv file. Can anyone give me an example of how to do that?

like image 648
kallem Avatar asked Jan 25 '11 08:01

kallem


People also ask

How do I export data from a table in Excel?

On the External Data tab, in the Export group, click Excel. In the Export - Excel Spreadsheet dialog box, review the suggested file name for the Excel workbook (Access uses the name of the source object). If you want, you can modify the file name. In the File Format box, select the file format that you want.


1 Answers

In psql:

\copy tablename to 'filename' csv; 
like image 173
Peter Eisentraut Avatar answered Sep 19 '22 20:09

Peter Eisentraut