Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I get a CSV header but no row count in PostgreSQL?

When I do psql --no-align --field-separator ',', I get CSV output with a header containing field names and a trailer telling me how many rows were found. To pass that into an analysis program, I need the header but not the trailer. I can surely write a filter to pass the first N-1 lines of the psql output but I'd prefer to suppress the trailer. Is there an option I'm missing that will turn on the header with --tuples-only or turn off the trailer?

like image 857
Chris Nelson Avatar asked Oct 08 '12 14:10

Chris Nelson


People also ask

How do you find the number of rows in a table in Postgres?

The basic SQL standard query to count the rows in a table is: SELECT count(*) FROM table_name; This can be rather slow because PostgreSQL has to check visibility for all rows, due to the MVCC model.

What is tuple in Postgres?

A tuple is PostgreSQL's internal representation of a row in a table. A single row may have many tuples representing it, but only one of these tuples will be applicable at any single point in time.


1 Answers

psql --no-align --field-separator ',' --pset footer will turn off the row summary footer

like image 81
dbenhur Avatar answered Sep 17 '22 08:09

dbenhur