Skip to content

Instantly share code, notes, and snippets.

@rafaelrozon
Created February 17, 2018 05:00
Show Gist options
  • Save rafaelrozon/996230d2c7fbd97d261676a197521bf8 to your computer and use it in GitHub Desktop.
Save rafaelrozon/996230d2c7fbd97d261676a197521bf8 to your computer and use it in GitHub Desktop.
$ psql -U postgres
$ use mydb
$ COPY (
select array_to_json(array_agg(row_to_json(t)))
from (
select *
from my_table
) t
)
TO '/path/to/file/file.json';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment