Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7713211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:49:03+00:00 2026-06-01T01:49:03+00:00

How do you hide the column names and row count in the output from

  • 0

How do you hide the column names and row count in the output from psql?

I’m running a SQL query via psql with:

psql --user=myuser -d mydb --output=result.txt -c "SELECT * FROM mytable;"

and I’m expecting output like:

1,abc
2,def
3,xyz

but instead I get:

id,text
-------
1,abc
2,def
3,xyz
(3 rows)

Of course, it’s not impossible to filter the top two rows and bottom row out after the fact, but it there a way to do it with only psql? Reading over its manpage, I see options for controlling the field delimiter, but nothing for hiding extraneous output.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:49:05+00:00Added an answer on June 1, 2026 at 1:49 am

    You can use the -t or --tuples-only option:

    psql --user=myuser -d mydb --output=result.txt -t -c "SELECT * FROM mytable;"

    Edited (more than a year later) to add:

    You also might want to check out the COPY command. I no longer have any PostgreSQL instances handy to test with, but I think you can write something along these lines:

    psql --user=myuser -d mydb -c "COPY mytable TO 'result.txt' DELIMITER ','"

    (except that result.txt will need to be an absolute path). The COPY command also supports a more-intelligent CSV format; see its documentation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to be able to output data from PowerShell without any column headings.
Is it possible to 'hide' a column in an Oracle 10g database, or prevent
How to show and hide one particular column in Mouse Over and Mouse out
I have a table column I’m trying to expand and hide. jQuery seems to
I am trying to hide some divs before the user prints this giant form,
I need to hide a Windows form from the taskbar but I can't use
I would like to hide the entire age column on this table. <table id=displayTable>
I want to hide ID column in my GridView, I knew the code GridView1.Columns[0].Visible
Here is my code, please help me hide the id column in jqGrid, I
Here's my problem. I have three controls in a row (they capture people's names).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.