---
title: "Postgres: Export a query to CSV on the client side"
tags: postgres
created: 2024-09-27 09:20
---

# Postgres: Export a query to CSV on the client side 

Execute the follow sentence in an **interactive session** of psql:

```sql
\copy (
    Select * From foo
) TO '/tmp/test.csv' WITH CSV DELIMITER ';' HEADER
```

