sqlite3 command-line - How to show less/more output

You can use sqlitestudio instead which sends output to a window with a scrollbar. https://sqlitestudio.pl/index.rvt


It does not seem to have something built-in. However, you can use Cntrl+PgUp and Cntrl+PgDn to move up and down from different pages in a terminal (in Ubuntu is gnome-terminal by default, so that should work).

Also, you can call commands from the shell, like in:

$ echo .help | sqlite3 2>&1 | more

sqlite3 prints the output in stderr, therefore the redirection 2>&1. For SQL commands, you can use:

$ sqlite3 my.db "select * from my_table;" | more

And so on.


From the dbcli collection the sqlite compatible litecli emerged in 2018. It can use either the $PAGER environment variable or a defined pager in ~/.config/litecli/config. As the util offers color support, I set it to less -SniFXR(?).

Another method is to let sqlite3 write to an output file/pipe and use less -f -S /tmp/sqlpipe in a second terminal window or tmux pane to read it. Enable with

.shell mkfifo /tmp/sqlpipe
.output /tmp/sqlpipe

It will look like this.

For not having to repeatedly enter the commands, a ~/.sqliterc can be used to set them at startup. Further formatting improves the output, though in the end litecli is a much more comfortable solution.