3

I am using following psql query to connect to a remote host and split a big table into multiple csv files.

psql -h xx -p xx -U xx -d xx -c "\COPY (select * from table) TO program 'split --lines 1000' (format csv)

I am not getting what mistake I am making here.

rshar
  • 1,381
  • 10
  • 28

1 Answers1

3

Have you tried using STDOUT?

$ psql -d db -c "COPY (SELECT * FROM t) TO STDOUT CSV " | split -1000
Jim Jones
  • 18,404
  • 3
  • 35
  • 44