verticavsql

Vertica include column names in output, but not row count footer


I am running some Vertica SQL queries from the command line and saving them to CSVs.

I want to keep column names, so I do not use the -t option. The problem is that I now am also left with the footer which gives the row count (e.g. (20 rows). I know that I could remove this footer in a separate command (as it will always be in the last row), but I was wondering if there is a more elegant solution.

I have been looking at the documentation here:

https://my.vertica.com/docs/7.1.x/HTML/Content/Authoring/ConnectingToHPVertica/vsql/CommandLineOptions.htm


Solution

  • Use \pset footer off.

    More info on the metacommand is available at the documentation.

    Example:

    dbadmin=> select count(*) from sessions;
     count
    -------
         5
    (1 row)
    
    dbadmin=> \pset footer off
    Default footer is off.
    dbadmin=> select count(*) from sessions;
     count
    -------
         5