MySQL Dummy Guide: How To Display Long SQL Output In Page By Page Fashion?
After posting the earlier MySQL dummy guide, I found another easier way to display long SQL result in page by page fashion (tested in MySQL server version 4.1.7).
Unlike the previous post, you don’t have to write down the SQL statements in a script file and redirect it to the MySQL Command-line Tool (i.e. the
Indeed, the
MySQL Command-line Tool: How to pipe long SQL output to the
Happy using MySQL database, one of the open source and most popular relational database system as of today!

mysql that also known as MySQL Monitor).Indeed, the
mysql build in a feature that allows user specify pager program (e.g. more or less in Linux-based system) to display long SQL output one page at a time.MySQL Command-line Tool: How to pipe long SQL output to the
less or more pager?- The first way is to start up MySQL Command-line Tool with
--pageroption switch that tellsmysqlto interactively display or show SQL results one page at a time, by using the pager program specified in $PAGER environment variable.
In my RHEL environment, the two default pager programs arelessandmore. The $PAGER environment variable, however, is not set by default installation.
Thus, in order to use--pageroption switch, I need to setup the $PAGER environment variable before invoking MySQL Command-line Tool with –pager option switch:
export PAGER=more mysql --pager -u walkernewsadmin -p
- This second method doesn’t need to setup $PAGER environment variable. Before executing the SQL command, run the mysql command
pager moreto instruct MySQL Command-line Tool to pipe subsequent SQL results to the Linux pager program that calledmore. To disable the pager program, simply executenopagermysql command. For examplemysql>
pager morePAGER set to 'more' mysql>select option_name from wp_options;mysql>nopagerPAGER set to stdout
To use other Linux pager program, e.g.less, simply replacemorewithless, i.e.pager less
Happy using MySQL database, one of the open source and most popular relational database system as of today!
Custom Search







2010 •