How to Export PostGres table to .CSV file in a simple way?
Export PostgreSQL Table Data To CSV File
In my previous article I explained about How to import data from .CSV in PostGres table in a simple way? Here I will show how to Export postgres table to .CSV file in a simple way. Execute the below query to export postgres table to .csv file.
Query - Export data to .CSV in PostGres
Copy (SELECT tracklocationid, msisdnnumber, lat, lng, createdon
FROM tracklocation
where msisdnnumber= '9833922076' and lat!='0'
order by tracklocationid desc) To 'D:/tracklocation.csv' With CSV;
--
Query - Export Postgres table to CSV file with headings
Copy (SELECT tracklocationid, msisdnnumber, lat, lng, createdon
FROM tracklocation
where msisdnnumber= '9833922076' and lat!='0'
order by tracklocationid desc) To 'D:/tracklocation.csv' DELIMITER ',' CSV HEADER;
Download the exported sample file from here
How to Export PostGres table to .CSV file in a simple way?
Reviewed by Ravi Kumar
on
5:56 PM
Rating:
No comments: