Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exit from query result viewer in psql?

Tags:

First query:

database=# select * from table limit 1; ...  | (1 row)  (END) 

I want to make a second query but I can't. ctrl+Z exits from psql. What can I press to exit only from result viewing?

like image 298
Иван Петров Avatar asked Dec 26 '15 20:12

Иван Петров


People also ask

How do I clear the screen in PostgreSQL?

Use \! cls to clear screen.

What is psql view?

A view can be accessed as a virtual table in PostgreSQL. In other words, a PostgreSQL view is a logical table that represents data of one or more underlying tables through a SELECT statement. Notice that a view does not store data physically except for a materialized view.

What does psql return?

psql returns 0 to the shell if it finished normally, 1 if a fatal error of its own occurs (e.g., out of memory, file not found), 2 if the connection to the server went bad and the session was not interactive, and 3 if an error occurred in a script and the variable ON_ERROR_STOP was set.

How do I view PostgreSQL views?

The PostgreSQL views are created using the CREATE VIEW statement. The PostgreSQL views can be created from a single table, multiple tables, or another view. CREATE [TEMP | TEMPORARY] VIEW view_name AS SELECT column1, column2..... FROM table_name WHERE [condition];


1 Answers

Hit q. This closes many vim-like views, not only in psql, but also e.g. in 'less', 'git log', 'mutt', and many more.

Just FYI: Hitting Ctrl + Z does not exit psql, it just suspends it and sends it to background. The program continues to run, and you can resume it by entering 'fg'. In Unix environments, Ctrl + C is usually the way to forcibly stop a program.

like image 116
andreas-hofmann Avatar answered Nov 01 '22 11:11

andreas-hofmann