updated Dec 29, 2019

How to export query output from Postgres SQL client into Google spreadsheet

You want to copy SQL SELECT results from the Postgres SQL console client into a Google spreadsheet document to share with other people. But there are problems: the columns formatting and paging.

How to change Postgres SQL client data formatting

  • Launch Postgres console SQL client
  • Switch to not aligned output:
    \a
  • Change the column data separator to tab:
    \f '\t'
  • Disable pager:
    \pset pager off
  • Execute SQL SELECT
  • Copy output and paste into Google spreadsheet