Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We switched from PostgreSQL 8.3 to 9.0. Perhaps it's a new feature or perhaps just a configuration change, but now when output from commands (like, \d tablename) exceeds visible vertical space, psql seem to pipe the output through something similar to less. I could not find a way to turn this behaviour off. Any advice? Thanks.

P.S. I'm scrolling the buffer using PuTTY's Shift+PgUp/PgDn so I don't need psql's paging. Plus, when I press q in the psql's paging, its output disappears from the screen entirely (just like after running less in bash), which is wrong from the general use-cases point of view.

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

There is documentation for that.

From the \pset section of the psql manual:

pager

Controls use of a pager program for query and psql help output. If the environment variable PAGER is set, the output is piped to the specified program. Otherwise a platform-dependent default (such as more) is used.

When the pager option is off, the pager program is not used. When the pager option is on, the pager is used when appropriate, i.e., when the output is to a terminal and will not fit on the screen. The pager option can also be set to always, which causes the pager to be used for all terminal output regardless of whether it fits on the screen. \pset pager without a value toggles pager use on and off.

share|improve this answer
2  
Thank you. The complete solution looks like: psql -P pager. –  Yuri Ushakov Feb 14 '11 at 9:50
1  
I guess you can even put an option in your ~/.psqlrc file to avoid having to enter this every time. –  SvW Feb 14 '11 at 9:52
    
Anyway to pass arguments to less? –  snapfractalpop Nov 7 '12 at 21:17
    
@snapfractalpop: Please post this as a new question. –  SvW Nov 7 '12 at 21:32
    
I also ran into Yuri's problem. As described above. You can use \pset pager in psql to toggle whether the output goes to the pager. However, you should be able to use a pager and not have the output disappear from the screen when you quit. The answer is to use 'more' instead of 'less' as the pager. You can either do that by setting the PAGER environment variable in your shell or by adding a PAGER environment variable to a ~/.psqlrc file. –  Michael Rush Apr 4 at 16:29
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.