Thursday 9 November 2017

Exporting/Importing to/from CSV in Postgres using the command line

Export \copy (query) to  'path\file.csv' delimiter as '$', NULL as E' ';

\copy does not require superuser privileges. copy does.

Import
\copy <table_name> from 'path\to\csv' delimiter as '$';