Write selected rows to a CSV file.
Section: Move data in and out
Export a query result to CSV
text
text
.headers on
.mode csv
.once recent_users.csv
SELECT id, email, created_at FROM users ORDER BY created_at DESC LIMIT 100;Explanation
Good for ad hoc reporting and support workflows.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Move data in and out
Import CSV with mode and separator
Set shell parsing options before import.
Create a compact backup with VACUUM INTO
Write a fresh copy of the database to a new file.