如何退出 PostgreSQL 命令行实用程序:psql
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9463318/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to exit from PostgreSQL command line utility: psql
提问by App Work
What command or short key can I use to exit the PostgreSQL command line utility psql
?
我可以使用什么命令或快捷键退出 PostgreSQL 命令行实用程序psql
?
回答by Frankline
Type \q
and then press ENTER
to quit psql
.
键入\q
,然后按ENTER
退出psql
。
UPDATE: 19-OCT-2018
更新:2018 年 10 月 19 日
As of PostgreSQL 11, the keywords "quit
" and "exit
" in the PostgreSQL command-line interface have been included to help make it easier to leave the command-line tool.
从PostgreSQL 11 开始,PostgreSQL 命令行界面中的关键字“ quit
”和“ exit
”已被包含在内,以帮助更轻松地离开命令行工具。
回答by Ted
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:
我认为 psql 命令行的老手通常将其缩短为:
\q
回答by Kaarel
Ctrl+Dis what I usually use to exit psql console.
Ctrl+D是我通常用来退出 psql 控制台的。
回答by iusting
Try:
尝试:
- Ctrl+Z- this sends the
TSTP
signal (TSTP
is short for “terminal stop”) - Ctrl+\- this sends the
QUIT
signal
- Ctrl+ Z- 发送
TSTP
信号(TSTP
“终端停止”的缩写) - Ctrl+ \- 这发送
QUIT
信号
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
- Ctrl+ D- 这会发送
EOF
字符。EOF
代表“文件结束”。在这种具体情况下,它从 psql 子程序中退出,因为 shell 正在等待用户输入。这不应该是“要走的路”,因为它在以下情况下不起作用:- 之前输入任何其他字符 - 尝试输入一些空格,然后按Ctrl+ D,它不会退出 psql。
- 如果根本不需要用户输入
回答by Lukasz Szozda
quit
or exit
or \q
quit
或exit
或\q
Based on PostgreSQL 11 Beta 1 Released!:
User Experience Enhancements
Another feature that fell into this category was the inability to intuitively quit from the PostgreSQL command-line (psql). There has been numerous recorded complaints of users trying to quit with the quitand exitcommands, only to learn that the command to do so was \q.
We have heard your frustrations and have now added the ability to quit the command-line using the keywords quitand exitand hope that quitting a PostgreSQL session is now as enjoyable as using PostgreSQL.
用户体验增强
另一个属于此类别的功能是无法直观地退出 PostgreSQL 命令行 (psql)。有许多用户尝试使用quit和exit命令退出的记录投诉,结果发现这样做的命令是\q。
我们听到了您的不满,现在添加了使用关键字quit和exit退出命令行的功能,希望现在退出 PostgreSQL 会话和使用 PostgreSQL 一样愉快。
回答by Maurice Elagu
For Linux command line \q+ enter.
对于 Linux 命令行\q+输入。
Quiting with Ctrl+ Dalso is works
使用Ctrl+ D退出也是有效的
回答by sflitman
I learned that I could include \q in a batch .sql file, so I could have psql quit earlier from an \i operation.
我了解到我可以在批处理 .sql 文件中包含 \q,所以我可以让 psql 更早地从 \i 操作中退出。
回答by VinoCoder
Actually, \q
, exit
and CTRL + D
did'nt worked for me to exit from the psqlprogram.
其实\q
,exit
和CTRL + D
did'nt从工作对我来说,退出PSQL程序。
Ctrl + Shift + D
Worked for me. Hope it ll help someone :)
对我来说有效。希望它会帮助某人:)
My ubuntu version is 19.04
我的 ubuntu 版本是19.04
回答by Mike Chen
Specifically speaking, how to exit from the following status on Ubuntu 18.04.
具体来说,如何在Ubuntu 18.04上退出以下状态。
I put the original status as follows.
我把原来的状态如下。
postgres@user:~$
If psql is inputed, it changes to the new status as follows.
如果输入 psql,它会变成如下的新状态。
postgres@user:~$ psql
postgres=#
If \q is inputed, please see the operation.
如果输入\q,请看操作。
postgres@user:~$ \q
It changes to the original status as follows.
它更改为原始状态如下。
postgres@user:~$
The quick way is to kill the terminal. But I want to know other quit method without killing the terminal.
快速的方法是杀死终端。但我想知道其他退出方法而不杀死终端。
Thanks,
谢谢,