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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
psqldoesn’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:
… 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:
SELECT INTO. This works for pretty much anything, including ordinarySELECT,DELETE ... RETURNING,INSERT ... RETURNING,UPDATE ... RETURNING, etc. Then process the temporary table as desired.SELECT.CREATE TEMPORARY VIEWmakes a view that only exists for your session.\epsql command to open the last command in an external editor (specified with the env varEDITOR) where you can modify it more easily.SQLite won’t have a
\ecommand and I don’t think it has DML commands that can return result sets (... RETURNINGcommands). Otherwise most of that should apply there too.