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

  • SEARCH
  • Home
  • 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 9140019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:27:41+00:00 2026-06-17T09:27:41+00:00

I am running a psql command that executes a complex query. There’s nothing that

  • 0

I am running a psql command that executes a complex query. There’s nothing that query produces, as such, psql returns “(No rows)” in the output.

Is there a way to make psql to return an empty string?

I’ve tried using –pset=tuples-only=on and –pset=footer=off and -q in all variations, and it doesn’t seem to work.

Footer option works while in psql shell prompt, but doesn’t work from script.

Tried on 9.1.7, need this for 8.4, 9.1 and 9.2.

  • 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-17T09:27:41+00:00Added an answer on June 17, 2026 at 9:27 am

    May be good enough:

    $ psql -Axt -c 'select 1 where 1=0'
    

    produces an empty string

    EDIT following comments:
    The command above produces an empty line, so that includes and end-of-line.

    To produce nothing at all, remove the -x option.

    Not that it would make any difference to the shell anyway, as shown below:

    with -x:

    r=`psql -Atx -d test -c "select 1 where 1=0"`  
    echo $r | od -c  
    0000000  \n  
    0000001  
    

    without -x:

    r=`psql -At -d test -c "select 1 where 1=0"`
    echo $r | od -c
    0000000  \n
    0000001
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When running the following query in psql I get back 7 results: SELECT generate_series('2012-10-14',
Within a bash script I am running a sql query via 'psql -c '.
Running my script through Devel::NYTProf showed that the following portion of code took up
Running SQL Server 2008 (not R2). I have a few reports that have URLs
Running this query takes a long time: SELECT host,ip FROM arecords WHERE ip IN
I am constantly running commands like nohup psql -d db -f foo1.sql >& foo1.out
I'm new to psql, and am having some issues that I think are being
A postgres client is running a possibly long-running query. The client receives a SIGTERM.
Kill-9-signalling all postgres processes ignite errors immediately after the command: $ psql psql: could
I am trying to send input to a interactive command running via screen. Here

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.