I\'m using psql\'s \\dt to list all tables in a database and I need to save the results.
\\dt
What is the syntax to export the results of a psql command to a
Use the below query to store the result in a CSV file
\copy (your query) to 'file path' csv header;
Example
\copy (select name,date_order from purchase_order) to '/home/ankit/Desktop/result.csv' cvs header;
Hope this helps you.