Home How to exit from PostgreSQL command line utility: psql
Reply: 6

How to exit from PostgreSQL command line utility: psql

App Work
1#
App Work Published in 2012-02-27 10:17:44Z

What command or short key can I use to exit the PostgreSQL command line utility psql?

Frankline
2#
Frankline Reply to 2013-03-12 05:28:22Z

Type \q and then press ENTER to quit psql.

rink.attendant.6
3#
rink.attendant.6 Reply to 2015-03-23 06:01:49Z

Ctrl+D is what I usually use to exit psql console.

Ted
4#
Ted Reply to 2014-04-17 00:31:36Z

My usual key sequence is:

quit()
quit
exit()
exit
q
q()
!q
^C
help
Alt + Tab
google.com
Quit PSQL
\q

I think veterans of the psql command line usually shorten that to just:

\q
sflitman
5#
sflitman Reply to 2014-06-23 00:13:08Z

I learned that I could include \q in a batch .sql file, so I could have psql quit earlier from an \i operation.

Maurice Elagu
6#
Maurice Elagu Reply to 2015-10-21 09:34:46Z

For Linux command line \q + enter.

Quiting with Ctrl + D also is works

iusting
7#
iusting Reply to 2016-11-15 18:18:57Z

Try:

  • Ctrl+Z - this sends the TSTP signal (TSTP is short for “terminal stop”)
  • Ctrl+\ - this sends the QUIT signal

For curiosity:

  • Ctrl+D - this sends the EOF character. EOF stands for "end of file". In this concrete case it exits from the psql subprogram, as the shell is waiting for user input. This should not be 'the way to go' as it is not working if:
    • any other character is entered before - try entering some white spaces and then press Ctrl+D, it's not going to exit psql.
    • if the user input is not required at all
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.311395 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO