Save PL/pgSQL output from PostgreSQL to a CSV file

后端 未结 18 2282
名媛妹妹
名媛妹妹 2020-11-22 11:56

What is the easiest way to save PL/pgSQL output from a PostgreSQL database to a CSV file?

I\'m using PostgreSQL 8.4 with pgAdmin III and PSQL plugin where I run que

18条回答
  •  春和景丽
    2020-11-22 12:20

    If you have longer query and you like to use psql then put your query to a file and use the following command:

    psql -d my_db_name -t -A -F";" -f input-file.sql -o output-file.csv
    

提交回复
热议问题