Heim  >  Artikel  >  Datenbank  >  Linux下查询MySQL大量数据时的分页技巧

Linux下查询MySQL大量数据时的分页技巧

WBOY
WBOYOriginal
2016-06-07 16:51:32794Durchsuche

在Linux下使用MySQL(特指MySQL的客户端工具)进行查询,当数据比较多时,很快就一页一页的翻过去了,无法看清数据。 在Linux下是有办法看

在Linux下使用MySQL(特指MySQL的客户端工具)进行查询,当数据比较多时,,很快就一页一页的翻过去了,无法看清数据。

在Linux下是有办法看清每一页的数据的。可以用--pager参数

比如MySQL --pager=more
或者MySQL --pager=less

这样每显示满一页,就会等待你按键来翻页,比如按空格键。按q则退出此查询,不用等到全部显示完。

如果使用了--pager=less还可以按B键来往前翻页,看已经看过的数据。使用上下箭头键也可以逐行上下移动。

还可以在MySQL中使用pager命令,比如
[gulei@ARCH1220 ~]$ MySQL EICSNEW
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 15253 to server version: 5.0.17c-pro-gpl-cert

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

MySQL>pager less -S
PAGER set to 'less -S'

之后再使用select进行查询,过宽的行(超过屏幕宽度)也不会换行了,可以使用左右箭头键来横滚,数据显示整齐多了。

总之把pager指定为less以后,less的所有功能都可以使用了,包括前后翻页、左右横滚、查找字符串等等。用man less看一下手册就行了,功能多了。 

linux

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn