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 8302841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:23:05+00:00 2026-06-08T17:23:05+00:00

Some interactive shells have a built-in variable that always points to the results of

  • 0

Some interactive shells have a built-in variable that always points to the results of the previous command (for example in the python3 shell this variable is “_”).

Does any such variable exist in the Sqlite3 and Psql prompts?

  • 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-08T17:23:06+00:00Added an answer on June 8, 2026 at 5:23 pm

    psql doesn’t, and it’s not really a typical way to work with relational data. If you want to retain the result from a previous query, put it in a temporary table.

    Do you mean that you want to be able to:

    SELECT count(somecol), avg(someothercol) FROM _;
    

    … for example? ie you want to be able to use your “last result” set and perform further processing on it?

    If so, it’s usually best to:

    • Put the results into a temporary table using SELECT INTO. This works for pretty much anything, including ordinary SELECT, DELETE ... RETURNING, INSERT ... RETURNING, UPDATE ... RETURNING, etc. Then process the temporary table as desired.
    • Create a temporary view of the result. This will of course only work for SELECT. CREATE TEMPORARY VIEW makes a view that only exists for your session.
    • Use readline. Just press the up arrow to get to your previous command, edit as desired, re-run.
    • Use the \e psql command to open the last command in an external editor (specified with the env var EDITOR) where you can modify it more easily.

    SQLite won’t have a \e command and I don’t think it has DML commands that can return result sets (... RETURNING commands). Otherwise most of that should apply there too.

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

Sidebar

Related Questions

I need some example Jython, or Java, code to exec an interactive OS shell
Is there some sort of interactive ActionScript interpreter? Similar to Firebug's JavaScript command line
I have a shell script and this one is interactive and I am creating
I've got some Workflow Foundation 4 ActivityDesigners that I'd like to have interact with
I have been working on some jQuery code for an interactive map. I've already
I'm working on an interactive shell where the user is entering some text, and
I wonder if we can have in Rails an interactive shell when exceptions occurs
I usually use perl -de 42 for obtaining an interactive Perl shell. I have
I am writing a couple Linux shell scripts that move some code around and
I am using some interactive/dynamic SVG on my site and as a feature we

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.