- Open a terminal and login to your database using below command (LINUX)
$ psql -h [HOST-STRING] -d [DATABASE-NAME] -U [USERNAME]
- Now use below command to export data from your database to CSV file
$ \copy (Table/Query) to [path-to-csvfile] csv header
\copy "user" to /home/myuser/Desktop/thesite-stg-user-data.csv csv header
\copy (select id,email,phone from "user" order by id) to /home/myuser/Desktop/thesite-stg-user-data.csv csv header