Problem Solution Discussion Preventing Query Output from Scrolling off the Screen

+----------+ +---------------------+ | NOW | +---------------------+ | 2001-07-04 10:42:22 | +---------------------+

1.18.4 See Also

By default , result s generat ed by queries t hat are specified wit h - e are displayed in t abular form at if out put goes t o t he t erm inal, and in t ab-delim it ed form at ot herwise. To produce a different out put st yle, see Recipe 1.22 .

1.19 Using Copy and Paste as a mysql Input Source

1.19.1 Problem

You want t o t ake advant age of your graphical user int erface GUI t o m ake m ysql easier t o use.

1.19.2 Solution

Use copy and past e t o supply m ysql wit h queries t o execut e. I n t his way, you can t ake advant age of your GUI s capabilit ies t o augm ent t he t erm inal int erface present ed by m ysql.

1.19.3 Discussion

Copy and past e is useful in a windowing environm ent t hat allows you t o run m ult iple program s at once and t ransfer inform at ion bet ween t hem . I f you have a docum ent cont aining queries open in a window, you can j ust copy t he queries from t here and past e t hem int o t he window in which youre running m ysql. This is equivalent t o t yping t he queries yourself, but oft en quicker. For queries t hat you issue frequent ly, keeping t hem visible in a separat e window can be a good way t o m ake sure t heyre always at your fingert ips and easily accessible.

1.20 Preventing Query Output from Scrolling off the Screen

1.20.1 Problem

Query out put zoom s off t he t op of your screen before you can see it .

1.20.2 Solution

Tell m ysql t o display out put a page at a t im e, or run m ysql in a window t hat allows scrollback.

1.20.3 Discussion

I f a query produces m any lines of out put , norm ally t hey j ust scroll right off t he t op of t he screen. To prevent t his, t ell m ysql t o present out put a page at a t im e by specifying t he - - pager opt ion. [ 6] - - pager = program t ells m ysql t o use a specific program as your pager : [ 6] The - - pager opt ion is not available under Windows. mysql --pager=usrbinless - - pager by it self t ells m ysql t o use your default pager, as specified in your PAGER environm ent variable: mysql --pager I f your PAGER variable isnt set , you m ust eit her define it or use t he first form of t he com m and t o specify a pager program explicit ly. To define PAGER , use t he inst ruct ions in Recipe 1.9 for set t ing environm ent variables. Wit hin a m ysql session, you can t urn paging on and off using \P and \n . \P wit hout an argum ent enables paging using t he program specified in your PAGER var iable. \P wit h an argum ent enables paging using t he argum ent as t he nam e of t he paging program : mysql \P PAGER set to binmore mysql \P usrbinless PAGER set to usrbinless mysql \n PAGER set to stdout Out put paging w as int roduced in MySQL 3.23.28. Anot her way t o deal wit h long result set s is t o use a t erm inal program t hat allows you t o scroll back t hrough previous out put . Program s such as xt erm for t he X Window Syst em , Term inal for Mac OS X, MacSSH or Bet t erTelnet for Mac OS, or Telnet for Windows allow you t o set t he num ber of out put lines saved in t he scrollback buffer. Under Windows NT, 2000, or XP, you can set up a DOS window t hat allows scrollback using t he following procedure: 1. Open t he Cont rol Panel. 2. Cr eat e a shor t cut t o t he MS- DOS prom pt by right clicking on t he Console it em and dragging t he m ouse t o w here you w ant t o place t he shor t cut on t he deskt op, for exam ple . 3. Right click on t he short cut and select t he Propert ies it em from t he m enu t hat appears. 4. Select t he Layout t ab in t he result ing Propert ies w indow . 5. Set t he screen buffer height t o t he num ber of lines you w ant t o save and click t he OK but t on. Now you should be able t o launch t he short cut t o get a scrollable DOS window t hat allows out put produced by com m ands in t hat window t o be ret rieved by using t he scrollbar.

1.21 Sending Query Output to a File or to a Program