export table to csv on postgres

csv, export-to-csv, postgresql

Solution

Use psql and redirect stream to file:

psql -U <USER> -d <DB_NAME> -c "COPY <YOUR_TABLE> TO stdout DELIMITER ',' CSV HEADER;" > file.csv

Problem

How can I export a table to `.csv` in Postgres, when I'm not superuser and can't use the `copy` command? I can still import the data to postgres with "import" button on the right click, but no export option.

Original source