Thread: How to prevent clear screen when query finish?
Hello, sorry for dumb question, did any one can tell me how the hell I can remove clear screen after finish the sql query from console ? This probably have some idea, but for me look like very ... not good idea. When I run query from console like: SELECT * FROM table_x; I got the result ... with (END) and when I click key -> q for quit the result disappear and I can't scroll it back, if I need to check something again (change console do something, get one line and need to scroll back) and want to see my old result again, I need to run query again ... I never has this problem on Slackware, but today one of my partners give me a shell to his ubuntu server to fix something on database. Cheers, Hristo S.
On 08/07/2013 08:53 AM, Condor wrote: > Hello, > > sorry for dumb question, did any one can tell me how the hell I can > remove clear screen after finish the sql query from console ? > This probably have some idea, but for me look like very ... not good > idea. When I run query from console like: > > SELECT * FROM table_x; > > I got the result ... with (END) and when I click key -> q for quit the > result disappear and I can't scroll it back, > if I need to check something again (change console do something, get one > line and need to scroll back) and want to see my old result again, I > need to run query > again ... I never has this problem on Slackware, but today one of my > partners give me a shell to his ubuntu server to fix something on database. > The pager is probably not set, see here for more info: http://www.postgresql.org/docs/9.2/interactive/app-psql.html 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. > > Cheers, > Hristo S. > > -- Adrian Klaver adrian.klaver@gmail.com
On 2013-08-07 19:01, Adrian Klaver wrote: > On 08/07/2013 08:53 AM, Condor wrote: >> Hello, >> >> sorry for dumb question, did any one can tell me how the hell I can >> remove clear screen after finish the sql query from console ? >> This probably have some idea, but for me look like very ... not good >> idea. When I run query from console like: >> >> SELECT * FROM table_x; >> >> I got the result ... with (END) and when I click key -> q for quit the >> result disappear and I can't scroll it back, >> if I need to check something again (change console do something, get >> one >> line and need to scroll back) and want to see my old result again, I >> need to run query >> again ... I never has this problem on Slackware, but today one of my >> partners give me a shell to his ubuntu server to fix something on >> database. >> > > The pager is probably not set, see here for more info: > > http://www.postgresql.org/docs/9.2/interactive/app-psql.html > > 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. > Thank you, last question: How I can find where is set this ENV ? because: # env TERM=xterm SHELL=/bin/bash SSH_CLIENT=192.68.1.111 52614 22 SSH_TTY=/dev/pts/2 USER=root LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01; 35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36: MAIL=/var/mail/root PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games PWD=/root LANG=en_US.UTF-8 PS1=\h:\w\$ SHLVL=1 HOME=/root LANGUAGE=en_US LS_OPTIONS=--color=auto LOGNAME=root SSH_CONNECTION=192.68.1.111 52614 192.68.1.121 22 HISTTIMEFORMAT=[%Y-%m-%d %T] _=/usr/bin/env OLDPWD=/root and when I enter to db: my_db=# \set AUTOCOMMIT = 'on' PROMPT1 = '%/%R%# ' PROMPT2 = '%/%R%# ' PROMPT3 = '>> ' VERBOSITY = 'default' VERSION = 'PostgreSQL 9.1.9 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3, 64-bit' DBNAME = 'my_db' USER = 'postgres' HOST = '127.0.0.1' PORT = '5432' ENCODING = 'UTF8' my_db=# I can't see this variable PAPER but yes, \pset paper work for connection. Cheers, Hristo S. > -- > Adrian Klaver > adrian.klaver@gmail.com
I think you mean PAGER, not PAPER.
I usually do this:
PAGER=more psql
This will set it for the connection, and it lets me use less as a pager by default elsewhere. You might also see what you can do to set it locally if you want to change it for everything.
Cheers,
Hristo S.--
Adrian Klaver
adrian.klaver@gmail.com
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
Best Wishes,
Chris Travers
Efficito: Hosted Accounting and ERP. Robust and Flexible. No vendor lock-in.
On 7 August 2013 18:01, Adrian Klaver <adrian.klaver@gmail.com> wrote:
On 08/07/2013 08:53 AM, Condor wrote:http://www.postgresql.org/docs/9.2/interactive/app-psql.html
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.--
If you use less for pager and want this behaviour system-wide, you'll want to set another env variable: setenv LESS -X (I use tcsh) or export LESS=-X if you use bash.
That makes less behave properly (not clearing the screen) after closing man-pages and such.
--
If you can't see the forest for the trees,
Cut the trees and you'll see there is no forest.
On 08/08/2013 12:09 AM, Condor wrote: > On 2013-08-07 19:01, Adrian Klaver wrote: >> On 08/07/2013 08:53 AM, Condor wrote: > >> > > > Thank you, > last question: How I can find where is set this ENV ? > because: > > > I can't see this variable PAPER but yes, \pset paper work for connection. If you don't want to deal with ENV you could use a psqlrc file: http://www.postgresql.org/docs/9.2/static/app-psql.html Files Unless it is passed an -X or -c option, psql attempts to read and execute commands from the system-wide psqlrc file and the user's ~/.psqlrc file before starting up. (On Windows, the user's startup file is named %APPDATA%\postgresql\psqlrc.conf.) See PREFIX/share/psqlrc.sample for information on setting up the system-wide file. It could be used to set up the client or the server to taste (using the \set and SET commands). The location of the user's ~/.psqlrc file can also be set explicitly via the PSQLRC environment setting. Both the system-wide psqlrc file and the user's ~/.psqlrc file can be made psql-version-specific by appending a dash and the PostgreSQL major or minor psql release number, for example ~/.psqlrc-9.2 or ~/.psqlrc-9.2.5. The most specific version-matching file will be read in preference to a non-version-specific file. > > Cheers, > Hristo S. > >> -- >> Adrian Klaver >> adrian.klaver@gmail.com > > -- Adrian Klaver adrian.klaver@gmail.com
Hi, I am trying some restore tools, can you advise how to find the latest transaction ID in PostgreSQL and the transaction IDat a particular "Point-In-Time"? regards
> From: "ascot.moss@gmail.com" <ascot.moss@gmail.com> > To: PostgreSQL general <pgsql-general@postgresql.org> > Cc: ascot.moss@gmail.com > Sent: Thursday, 8 August 2013, 14:52 > Subject: [GENERAL] How to find transaction ID > > Hi, > > I am trying some restore tools, can you advise how to find the latest > transaction ID in PostgreSQL and the transaction ID at a particular > "Point-In-Time"? > Hmm, it's not clear entirely what you want. Afaik "select txid_current()" should get you the current transaction id. Thecolumn xmin for a row from any table will get you the inserting transaction id, and xmax will get you the deleting (orattempted delete) transaction id. See http://www.postgresql.org/docs/9.0/static/functions-info.html
> From: Glyn Astill <glynastill@yahoo.co.uk> > To: "ascot.moss@gmail.com" <ascot.moss@gmail.com>; PostgreSQL general <pgsql-general@postgresql.org> > Cc: > Sent: Thursday, 8 August 2013, 15:20 > Subject: Re: [GENERAL] How to find transaction ID > > > >> From: "ascot.moss@gmail.com" <ascot.moss@gmail.com> >> To: PostgreSQL general <pgsql-general@postgresql.org> >> Cc: ascot.moss@gmail.com >> Sent: Thursday, 8 August 2013, 14:52 >> Subject: [GENERAL] How to find transaction ID >> >> Hi, >> >> I am trying some restore tools, can you advise how to find the latest >> transaction ID in PostgreSQL and the transaction ID at a particular >> "Point-In-Time"? >> > > Hmm, it's not clear entirely what you want. Afaik "select > txid_current()" should get you the current transaction id. The column xmin > for a row from any table will get you the inserting transaction id, and xmax > will get you the deleting (or attempted delete) transaction id. > > See http://www.postgresql.org/docs/9.0/static/functions-info.html > I guess I shouldn't have said that about xmin and xmax; you can't rely on those columns in various circumstances i.e. aftera vacuum.