When executing SQL in psql, sometimes the screen switches and you need to press q to return. That itself is not a problem, but once you press q, the previously displayed values disappear, so it can be inconvenient if you want to check “the previous values.”
In such cases, you can turn off the pager so that all SQL results remain visible while still moving on to the next prompt. In psql, the pager is automatically used when the results exceed the width of the screen.
How to turn off the pager
|
1 |
\pset pager off |
You can also disable it via an environment variable. Strictly speaking, this changes the program used by the pager rather than turning it off.
|
1 |
EXPORT PAGER=cat |
How to enable the pager
If you have turned off the pager and want to enable it again, do the following:
|
1 |
\pset pager on |
If you have set an environment variable, this alone will not restore it, so you need to change the environment variable.
psql automatically decides when to use the pager and when not to, but you can also force it to always use the pager.
How to always use the pager
|
1 |
\pset pager always |
In addition to these commands, running \pset pager toggles the pager on and off. If the pager is on, it will switch to off, and if it is off, it will switch to on.






